Advertisement
Guest User

Untitled

a guest
Dec 30th, 2012
143
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.96 KB | None | 0 0
  1. package com.bubudsadasdas;
  2.  
  3. import android.app.Activity;
  4. import android.content.ActivityNotFoundException;
  5. import android.content.Intent;
  6. import android.net.Uri;
  7. import android.os.Bundle;
  8. import android.util.Log;
  9.  
  10. public class phonecalls extends Activity {
  11. /** Called when the activity is first created. */
  12. @Override
  13. public void onCreate(Bundle savedInstanceState) {
  14. super.onCreate(savedInstanceState);
  15. setContentView(R.layout.main);
  16. call();
  17. }
  18.  
  19. private void call() {
  20. try {
  21. Intent callIntent = new Intent(Intent.ACTION_CALL);
  22. callIntent.setData(Uri.parse("tel:123456789"));
  23. startActivity(callIntent);
  24. } catch (ActivityNotFoundException activityException) {
  25. Log.e("dialing-example", "Call failed", activityException);
  26. }
  27. }
  28. }
  29.  
  30.  
  31.  
  32.  
  33. ///////////////////////outgoingcall reciever activity/////////////////
  34.  
  35.  
  36. import android.content.BroadcastReceiver;
  37. import android.content.Context;
  38. import android.content.Intent;
  39. import android.os.Bundle;
  40. import android.util.Log;
  41. import android.widget.Toast;
  42.  
  43. public class OutgoingCallReceiver extends BroadcastReceiver {
  44.  
  45. @Override
  46. public void onReceive(Context context, Intent intent) {
  47. Bundle bundle = intent.getExtras();
  48.  
  49. if(null == bundle)
  50. return;
  51.  
  52. String phonenumber = intent.getStringExtra(Intent.EXTRA_PHONE_NUMBER);
  53.  
  54. Log.i("OutgoingCallReceiver",phonenumber);
  55. Log.i("OutgoingCallReceiver",bundle.toString());
  56.  
  57. String info = "Detect Calls sample application\nOutgoing number: " + phonenumber;
  58.  
  59. Toast.makeText(context, info, Toast.LENGTH_LONG).show();
  60. if(intent.getAction().equals(Intent.ACTION_NEW_OUTGOING_CALL))
  61. {
  62. abortBroadcast ();
  63. }
  64. }
  65. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement