Skip to content Skip to sidebar Skip to footer

How To Get Dialed Mobile Number In My Application?

Possible Duplicate: launching my app when dialing a number I would like to get the mobile number from dialer which has dialed by user in my android application.I have implemente

Solution 1:

You can use BroadcastReceiverto do that :

Register a BroadcastReceiver like this in Manifest file:

<!-- DIAL Receiver --><receiverandroid:exported="true"android:name="receivers.DialBroadcastReceiver" ><intent-filter ><actionandroid:name="android.intent.action.NEW_OUTGOING_CALL" /></intent-filter></receiver>

You need Permission for NEW_OUTGOING_CALL :

<!-- OUTGOING CALL PERMISSION--><uses-permissionandroid:name="android.permission.PROCESS_OUTGOING_CALLS" />

Eventually you can Receive the broadcast and retrieve the dialed number like this:

publicclassDialBroadcastReceiverextendsBroadcastReceiver {

@OverridepublicvoidonReceive(Context context, Intent intent) {

    Log.v("DileBroadCastReceiver","In onReceive()");

    if (intent.getAction().equals(Intent.ACTION_NEW_OUTGOING_CALL)) {
         Stringnumber = intent.getStringExtra(Intent.EXTRA_PHONE_NUMBER);

         Log.v("DialBroadcast Receiver","Number is: "+number);

    }

}

}

Solution 2:

I got my solution as following code

publicclassOutGoingCallextendsBroadcastReceiver {

   @OverridepublicvoidonReceive(final Context context, final Intent intent) 
   {
         // get phone number from bundleStringphoneNumber= intent.getExtras().getString(OutGoingCall.INTENT_PHONE_NUMBER);

   }
}

Post a Comment for "How To Get Dialed Mobile Number In My Application?"