Intent.ACTION_CALL仅在Android 9 Pie中不起作用

时间:2019-11-21 10:35:54

标签: android android-intent

我也已经在清单文件上提供了ACTION_CALL permisiion,但是在android 9 pie中它不起作用。.IT也在android 10中工作

Intent intent = new Intent(Intent.ACTION_CALL);
                                    intent.setData(Uri.parse("tel:100"));
                                    startActivity(intent);

3 个答案:

答案 0 :(得分:0)

首先请确保您已在清单中设置了权限 <uses-permission android:name="android.permission.CALL_PHONE"/> 然后尝试这段代码

Intent intent = new Intent(Intent.ACTION_CALL, Uri.parse("tel:" + xxxxxxxx));
startActivity(intent);

如果要在没有任何许可的情况下进行操作,只需使用ACTION_DIAL而不是ACTION_CALL来预先填充拨号程序并让用户拨打电话

Intent intent = new Intent(Intent.ACTION_DIAL);
intent.setData(Uri.parse("tel:xxxxxxx"));
startActivity(intent);

答案 1 :(得分:0)

向清单文件中添加权限:-

<uses-permission android:name="android.permission.CALL_PHONE" />

意图:

  Intent in = new Intent(Intent.ACTION_DIAL);
            in.setData(Uri.parse("tel:" + your text));
            startActivity(in);

答案 2 :(得分:0)

清单文件中的ADD权限

<uses-permission android:name="android.permission.CALL_PHONE" />

添加意图

int number = 123 123 123
Intent i = new Intent(Intent.ACTION_DIAL);
startActivity(i.setData(Uri.parse("tel:" + number));)