无活动处理意向与action.DIAL [英] 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.
我有一个片段的活动。片段中调用联系人的目的,执行该code:
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);
}
还包括允许
<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?
推荐答案
您并不需要声明拨打意图过滤器清单中,不需要任何权限ACTION_DIAL。寻找我的执行
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 tm = (TelephonyManager)getSystemService(TELEPHONY_SERVICE);
return tm != null && tm.getSimState()==TelephonyManager.SIM_STATE_READY
}
这篇关于无活动处理意向与action.DIAL的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!