当我按下 android 中的按钮时,我正在尝试调用电话
((Button)findViewById(R.id.button1)).setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
String phno="10digits";
Intent i=new Intent(Intent.ACTION_DIAL,Uri.parse(phno));
startActivity(i);
}
});
但是当我运行并单击按钮时,它给了我错误
ERROR/AndroidRuntime(1021): android.content.ActivityNotFoundException: No Activity found to handle Intent { act=android.intent.action.CALL dat=9392438004 }
我该如何解决这个问题?
最佳答案
您是否在 list 文件中授予了权限
<uses-permission android:name="android.permission.CALL_PHONE"></uses-permission>
在你的 Activity 中
Intent callIntent = new Intent(Intent.ACTION_CALL);
callIntent.setData(Uri.parse("tel:123456789"));
startActivity(callIntent);
如果您发现任何问题,请告诉我。
关于android - 调用电话 点击按钮,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5403308/