找不到用于处理Intent的活动{act = android.intent.action.DIAL} [英] No Activity found to handle Intent { act=android.intent.action.DIAL }
问题描述
我想打开电话拨号器.但是显示错误.我已经在Android Manifest上声明了CALL_PHONE的权限,并且还在Android Manifest中声明了类.
I want to open my phone dialer .But it shows error. I have declared permissions for CALL_PHONE on Android Manifest and also declared class in Android Manifest.
case R.id.action_call:
Log.d("Action_call","INside Action call");
Intent dialer = new Intent(Intent.ACTION_DIAL);
startActivity(dialer);
return true;
推荐答案
对于 ACTION_DIAL
Intent,您不需要任何权限.因此,请从 CALL_PHONE
权限.
You don't need any permissions for ACTION_DIAL
Intent. So remove CALL_PHONE
permission from AndroidManifest.xml
.
您尚未传递任何号码来触发Intent.
You have not pass any number to fire dial Intent.
使用 tel:
,后接电话号码作为传递给Uri.parse()的值:
Use tel:
followed by the phone number as the value passed to Uri.parse():
尝试此代码.
String number = "1234567890";
Uri number = Uri.parse("tel:" + number);
Intent dial = new Intent(Intent.ACTION_DIAL);
dial.setData(number);
startActivity(dial);
您可以先检查设备上是否支持电话
You can first check whether telephony is supported on device
private boolean isTelephonyEnabled(){
TelephonyManager tm = (TelephonyManager)getSystemService(TELEPHONY_SERVICE);
return tm != null && tm.getSimState()==TelephonyManager.SIM_STATE_READY
}
希望对您有帮助!
这篇关于找不到用于处理Intent的活动{act = android.intent.action.DIAL}的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!