I am using this:
public void onCallStateChanged(int state, String incomingNumber)
which is listening to:
telephonyManager.listen(listener,PhoneStateListener.LISTEN_CALL_STATE);
I want to know both outgoing and incoming calls but for now I only get incoming calls (when state changes is ringing). Can anyone tell me when can I detect outgoing call and its end
Also is there a way to simulate outgoing calls in Eclipse emulator. was able to do that for incoming calls via emulator control in eclipse.
Navigate to Restrictions -> Phone. Under Calls, find the Outgoing calls option and click on Restrict to block outgoing calls on Android devices. Next, Save and Publish the restrictions profile. It is recommended to test the profile on a test device before associating it with your production environment.
Detecting incoming and outgoing calls in Android can be realized in several ways. One of the possibilities is to use a custom PhoneStateListener which can be attached to the TelephonyManager in your onReceive() function of the custom BroadcastReceiver.
Use a broadcast listener with an intent android.intent.action.NEW_OUTGOING_CALL
string parametrer for the IntentFilter
and don't forget to give permission in AndroidMenifest to PROCESS_OUTGOING_CALLS
. This will work. Whenever there is an outgoing call a toast message will be shown. Code is below.
public static final String outgoing = "android.intent.action.NEW_OUTGOING_CALL" ;
IntentFilter intentFilter = new IntentFilter(outgoing);
BroadcastReceiver OutGoingCallReceiver = new BroadcastReceiver()
{
@Override
public void onReceive(Context context, Intent intent)
{
// TODO Auto-generated method stub
String outgoingno = intent.getStringExtra(Intent.EXTRA_PHONE_NUMBER);
Toast.makeText(context, "outgoingnum =" + outgoingno,Toast.LENGTH_LONG).show();
}
};
registerReceiver(brForOutgoingCall, intentFilter);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With