Sakkeer Hussain Sakkeer Hussain - 1 year ago 120
Android Question

How to set intent filter for dial action in android?

I am trying to create a simple dial pad. I created all that and now I like to receive action dial intent from other applications.


<action android:name="android.intent.action.DIAL" />

<category android:name="android.intent.category.DEFAULT" />

<data android:xxxxxx="XXXXXX" />


and now I don't know what should be filled with the data in action filter.
Can anyone help me ?
Thanks in advance.

Answer Source

This is the intent filter should be used.

<action android:name="android.intent.action.CALL_DIAL" />                
<category android:name="android.intent.category.LAUNCHER" />
<category android:name="android.intent.category.DEFAULT" />
<data android:scheme="tel" />

And we can read the phone number from onCreate methord like this.

protected void onCreate(Bundle savedInstanceState) {

        //start reading here
        Intent intent = getIntent();
            Log.d("intent received",intent.getData().toString());
            String phoneNumber = intent.getData().toString(); //contains tel:phone_no
            phoneNumber = phoneNumber.substring(4);
            Log.d("intent received","Received phone number : "+phoneNumber);
                  /// do what you like here
            Log.d("intent received","null intent received");
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download