我似乎缺乏处理此类 Intent 的知识,但是暂时找不到答案。
我有一个 fragment 的 Activity 。该 fragment 执行此代码以调用联系人:
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>
输出是No Activity found to handle Intent
,应用崩溃。
这是包含 fragment 的 Activity 的 list 实现:
<activity android:name="activities.ContactActivity">
<intent-filter>
<action android:name="android.intent.action.DIAL" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
我做错了什么?为此,我需要在 list 中声明一些特殊 Activity 吗?
最佳答案
您不需要在 list 中声明 dial intent-filter,也不需要任何 ACTION_DIAL 权限。寻找我的实现
private void startDialActivity(String phone){
Intent intent = new Intent(Intent.ACTION_DIAL);
intent.setData(Uri.parse("tel:"+phone));
startActivity(intent);
}
还可以检查设备是否支持电话
private boolean isTelephonyEnabled(){
TelephonyManager telephonyManager = (TelephonyManager)getSystemService(TELEPHONY_SERVICE);
return telephonyManager != null && telephonyManager.getSimState()==TelephonyManager.SIM_STATE_READY;
}
关于android - 找不到使用 action.DIAL 处理 Intent 的 Activity ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16236504/