Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
1.2k views
in Technique[技术] by (71.8m points)

android - 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?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

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;
}

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

2.1m questions

2.1m answers

60 comments

57.0k users

...