找不到处理Intent{act=android.Intent.action.DIAL}的活动
我想打开我的电话拨号器。但它显示错误。我已经在Android清单上声明了CALL_PHONE的权限,也在Android清单中声明了类找不到处理Intent{act=android.Intent.action.DIAL}的活动,android,android-intent,Android,Android Intent,我想打开我的电话拨号器。但它显示错误。我已经在Android清单上声明了CALL_PHONE的权限,也在Android清单中声明了类 case R.id.action_call: Log.d("Action_call","INside Action call"); Intent dialer = new Intent(Intent.ACTION_DIAL); startActivity(dialer); return true; 您不需要对操作拨号意图有任何权限。因此,从AndroidMani
case R.id.action_call:
Log.d("Action_call","INside Action call");
Intent dialer = new Intent(Intent.ACTION_DIAL);
startActivity(dialer);
return true;
您不需要对
操作拨号
意图有任何权限。因此,从AndroidManifest.xml
中删除CALL\u PHONE
权限
您还没有传递任何号码来激活拨号意图
使用tel:
后跟电话号码作为传递给Uri.parse()的值:
试试这个代码
String number = "1234567890";
Uri number = Uri.parse("tel:" + number);
Intent dial = new Intent(Intent.ACTION_DIAL);
dial.setData(number);
startActivity(dial);
编辑:
您可以首先检查设备上是否支持电话
private boolean isTelephonyEnabled(){
TelephonyManager tm = (TelephonyManager)getSystemService(TELEPHONY_SERVICE);
return tm != null && tm.getSimState()==TelephonyManager.SIM_STATE_READY
}
我希望有帮助 使用
Uri
解析数字
Intent call = new Intent(Intent.ACTION_DIAL);
call.setData(Uri.parse("tel:"+phone)); //String phone
startActivity(call);
- 使用try/catch
- 使用Uri解析数字
- 不需要任何权限即可执行操作\拨号意图
try{ Intent call_intent = new Intent(Intent.ACTION_DIAL); call_intent.setData(Uri.parse("tel:"+phone_number)); startActivity(call_intent); }catch(Exception e){ }