Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

No Activity found to handle Intent with action.DIAL

I seems to be lacking knowledge about handling such intents, however couldnt find answer for a while.

I have an activity with one fragment. The fragment executes this code in purpose of calling a contact:

private void onCall() {
    Intent intent = new Intent(Intent.ACTION_DIAL, Uri.parse(contact.getBusinessPhone()));
    startActivity(intent);
}

Also included permission

<uses-permission android:name="android.permission.CALL_PHONE"></uses-permission> 

The output is No Activity found to handle Intent and the app crashes.

Here is manifest implementation of the activity that holds fragment:

<activity android:name="activities.ContactActivity">            
    <intent-filter>
        <action android:name="android.intent.action.DIAL" />
        <category android:name="android.intent.category.DEFAULT" />
    </intent-filter>
</activity>

What am I doing wrong? Do I need some special activity declared in manifest for that?

like image 684
Jacek Kwiecień Avatar asked Apr 26 '13 12:04

Jacek Kwiecień


2 Answers

You don't need to declare dial intent-filter in manifest and don't need any permissions to ACTION_DIAL. Look for my implementation

private void startDialActivity(String phone){
    Intent intent = new Intent(Intent.ACTION_DIAL);
    intent.setData(Uri.parse("tel:"+phone));
    startActivity(intent);
}

also is good to check is telephony supported on device

private boolean isTelephonyEnabled(){
    TelephonyManager telephonyManager = (TelephonyManager)getSystemService(TELEPHONY_SERVICE);
    return telephonyManager != null && telephonyManager.getSimState()==TelephonyManager.SIM_STATE_READY;
}
like image 148
Viacheslav Avatar answered Nov 02 '22 11:11

Viacheslav


Intent.ACTION_VIEW worked out better for me because on tablets without a dialer it automatically switched to "Add to Contact".

like image 9
dt0 Avatar answered Nov 02 '22 11:11

dt0