In an app I show some phone numbers in a textview that the user can tap on them to dial them (autoLink
set to phone
on the textview).
When I tap on the numbers the option to dial that number shows up.
My question is: Is there a way to figure out if the user actual pressed the dial button in the dial pad to actually do the call?
Detect if the user actually dialed a number programmatically
613 Views Asked by Jim At
3
There are 3 best solutions below
0

public class Outgoing_Call_Receiver extends BroadcastReceiver {
@Override
public void onReceive(Context context, Intent intent) {
if (intent.getAction().equals(Intent.ACTION_NEW_OUTGOING_CALL)) {
if(intent.getExtras().getString("android.intent.extra.PHONE_NUMBER").equals(new MyApp(context).getEmergencyNumber()));
}
}
}
Try this code. it will help you.
0

you can listen the event if dialpad opened or not if dialpad not opened then you can say its from the app..or like the same otherways. or you can call a webservice API with dialing a number from your code. Upon the responce you can detect its from your app not actually from dialpad or viceversa.
You can create a GSMBroadcastListener and receive events about the call state of the phone (Hangup, Ringing, Established, etc).
If you want to know, if it happened after a click on your phone button, just create this listener in the on-click event, so it will receive the events only if one of your buttons is clicked. Unhook (unregister) in the Hangup-Event after the call has ended, so will not receive events after the call.
Here is my implementation with an Listener Interface that works fine in a production app:
Code:
This class will forward GSM events to a listener that you add with
GSMBroadcastReceiver.registerGSMBroadcastListener
.To use it, you need this:
Register the receiver in your
manifest
Then, in the click listener of your phone number button, register a listener: (Note, that you unregister it in the onHangUp() callback!)
That's it! You should now get informed about GSM activity after your button click.
Hope this helps, cheers, Gris