Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to find outgoing number in Telephony manager

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.

like image 929
Swati Avatar asked Jul 07 '11 13:07

Swati


People also ask

How do I manage my outgoing calls?

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.

How do I find incoming and outgoing calls on Android?

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.


1 Answers

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);
like image 96
sush Avatar answered Oct 24 '22 19:10

sush