Home » Android » android – No Activity found to handle Intent with action.DIAL

android – No Activity found to handle Intent with action.DIAL

Posted by: admin May 14, 2020 Leave a comment

Questions:

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?

How to&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;
}

Answer:

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