簡體   English   中英

Intent.ACTION_CALL 僅在 android 9 派中不起作用

[英]Intent.ACTION_CALL not working only in android 9 pie

我也給了清單文件的 ACTION_CALL 權限,但是在 android 9 餡餅中它不起作用..它也在 android 10 中工作

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

首先確保您在清單中設置了權限<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);

在清單文件中添加權限:-

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

和意圖:

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

在清單文件中添加權限

<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));)

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM