I am developing an application where one of the things we need is to control the outgoing call, at least to be able to stop it from our application.
I've tried using Intent.ACTION_CALL
from an existing activity:
Intent callIntent = new Intent(Intent.ACTION_CALL, Uri.parse("tel:" + phoneNumber));
startActivity(callIntent);
But stopping the call seems to be disallowed through the API.
Can you suggest some workaround?
For example: enabling airplane mode during the call? Just an example; this hack didn't work for me.
Considering the potential for wonderful mischief I would be surprised if this is allowed.
This thread says flatly that the API cannot end a call. Others have tried.
You can try enabling then disabling airplane mode:
Try this:
(I used Reflection to access advanced telephony features and modify somethings)
Capturing the outgoing call in a
BroadcastReceiver
has been mentioned and is definitely the best way to do it if you want to end the call before dialing.Once dialing or in-call, however, that technique no longer works. The only way to hang up that I've encountered so far, is to do so through Java Reflection. As it is not part of the public API, you should be careful to use it, and not rely upon it. Any change to the internal composition of Android will effectively break your application.
Prasanta Paul's blog demonstrates how it can be accomplished, which I have summarized below.
Obtaining the
ITelephony
object:Ending the call:
According to the documentation on ACTION_NEW_OUTGOING_CALL
For Ilana:
In addition in Manifest put in package section:
That is all.