Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package com.bubudsadasdas;
- import android.app.Activity;
- import android.content.ActivityNotFoundException;
- import android.content.Intent;
- import android.net.Uri;
- import android.os.Bundle;
- import android.util.Log;
- public class phonecalls extends Activity {
- /** Called when the activity is first created. */
- @Override
- public void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- setContentView(R.layout.main);
- call();
- }
- private void call() {
- try {
- Intent callIntent = new Intent(Intent.ACTION_CALL);
- callIntent.setData(Uri.parse("tel:123456789"));
- startActivity(callIntent);
- } catch (ActivityNotFoundException activityException) {
- Log.e("dialing-example", "Call failed", activityException);
- }
- }
- }
- ///////////////////////outgoingcall reciever activity/////////////////
- import android.content.BroadcastReceiver;
- import android.content.Context;
- import android.content.Intent;
- import android.os.Bundle;
- import android.util.Log;
- import android.widget.Toast;
- public class OutgoingCallReceiver extends BroadcastReceiver {
- @Override
- public void onReceive(Context context, Intent intent) {
- Bundle bundle = intent.getExtras();
- if(null == bundle)
- return;
- String phonenumber = intent.getStringExtra(Intent.EXTRA_PHONE_NUMBER);
- Log.i("OutgoingCallReceiver",phonenumber);
- Log.i("OutgoingCallReceiver",bundle.toString());
- String info = "Detect Calls sample application\nOutgoing number: " + phonenumber;
- Toast.makeText(context, info, Toast.LENGTH_LONG).show();
- if(intent.getAction().equals(Intent.ACTION_NEW_OUTGOING_CALL))
- {
- abortBroadcast ();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement