Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on May 10th, 2012  |  syntax: None  |  size: 3.21 KB  |  hits: 17  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. Java/Android, Multiple Classes
  2. package com.abc.example;
  3.  
  4. import android.app.Activity;
  5. import android.content.Intent;
  6. import android.os.Bundle;
  7. import android.view.Menu;
  8. import android.view.MenuInflater;
  9. import android.view.MenuItem;
  10. import android.view.View;
  11. import android.widget.Button;
  12.  
  13. public class FindUs extends Activity {
  14.  
  15. @Override
  16. protected void onCreate(Bundle savedInstanceState) {
  17.     // TODO Auto-generated method stub
  18.     super.onCreate(savedInstanceState);
  19.     setContentView(R.layout.findUs);
  20.  
  21.             Button first = (Button) findViewById(R.id.first);
  22.             Button second = (Button) findViewById(R.id.second);
  23.             Button third = (Button) findViewById(R.id.third);
  24.             Button fourth = (Button) findViewById(R.id.fourth);
  25.  
  26.             first.setOnClickListener(new View.OnClickListener() {
  27.                 public void onClick(View v) {
  28.                     // TODO Auto-generated method stub
  29.                     startActivity(new Intent("com.abc.example.FIRST"));
  30.                 }
  31.             });
  32.  
  33.             second.setOnClickListener(new View.OnClickListener() {
  34.                 public void onClick(View v) {
  35.                     // TODO Auto-generated method stub
  36.                     startActivity(new Intent("ccom.abc.example.SECOND"));
  37.                 }
  38.             });
  39.  
  40.             third.setOnClickListener(new View.OnClickListener() {
  41.                 public void onClick(View v) {
  42.                     // TODO Auto-generated method stub
  43.                     startActivity(new Intent("com.abc.example.THIRD"));
  44.                 }
  45.             });
  46.  
  47.             fourth.setOnClickListener(new View.OnClickListener() {
  48.                 public void onClick(View v) {
  49.                     // TODO Auto-generated method stub
  50.                     startActivity(new Intent("com.abc.example.FOURTH"));
  51.                 }
  52.             });            
  53. }
  54.        
  55. package com.abc.example;
  56.  
  57. import android.app.Activity;
  58. import android.content.Intent;
  59. import android.net.Uri;
  60. import android.os.Bundle;
  61. import android.view.Menu;
  62. import android.view.MenuInflater;
  63. import android.view.MenuItem;
  64. import android.view.View;
  65. import android.widget.Button;
  66.  
  67. public class First extends Activity {
  68.  
  69. @Override
  70. protected void onCreate(Bundle savedInstanceState) {
  71.     // TODO Auto-generated method stub
  72.     super.onCreate(savedInstanceState);
  73.     setContentView(R.layout.first);
  74.  
  75.     Button callFirst= (Button) findViewById(R.id.callfirst);
  76.     Button mapFirst= (Button) findViewById(R.id.mapfirst);
  77.  
  78.     callFirst.setOnClickListener(new View.OnClickListener() {
  79.         public void onClick(View v) {
  80.             // TODO Auto-generated method stub
  81.             String phoneNumber = "tel:+18000000000";
  82.             Intent callIntent = new Intent(Intent.ACTION_CALL);
  83.             callIntent.setData(Uri.parse(phoneNumber));
  84.             startActivity(callIntent);
  85.  
  86.         }
  87.     });
  88.  
  89.     mapFirst.setOnClickListener(new View.OnClickListener() {
  90.         public void onClick(View v) {
  91.             // TODO Auto-generated method stub
  92.             String url = "grab google directions for this place";
  93.             Intent mapIntent = new Intent(android.content.Intent.ACTION_VIEW,  Uri.parse(url));
  94.             startActivity(mapIntent);
  95.                 }
  96.             });            
  97. }