簡體   English   中英

我已經創建了一個默認的撥號器應用,並且ACTION_CALL意圖在某些設備上不起作用

[英]I have created a default dialer app and the ACTION_CALL intent doesn't work on some devices

我創建了一個默認的撥號器應用程序,而ACTION_CALL意圖在某些設備上不起作用。

除非我將我的應用程序設置為默認電話應用程序,否則ACTION_CALL意圖非常有效。 但是,如果將我的應用程序設置為默認電話應用程序,它將無法正常工作。

我認為我的應用有問題。 但是,它在Samsung Galaxy S10E以外的大多數設備上都可以正常工作(在其他Android 9.0設備上也可以正常工作)。

如果我將我的應用程序設置為默認撥號器應用程序並發送ACTION_CALL意向,則會出現一個屏幕,供我選擇除我的應用程序以外的電話應用程序(使用“完成操作”)

設備沒有問題。 下方鏈接中的應用正常運行。( https://play.google.com/store/apps/details?id=com.skt.prod.dialer

請幫我。

/* call method */
void doCall(String phoneNo) {
    String tel = "tel:" + phoneNo;
    Intent callIntent = new Intent(Intent.ACTION_CALL);
    callIntent.setData(Uri.parse(tel));
    this.startActivity(callIntent);
}
/* InCallService */
<service
    android:name=".CallService"
    android:permission="android.permission.BIND_INCALL_SERVICE">
    <meta-data
        android:name="android.telecom.IN_CALL_SERVICE_UI"
        android:value="true" />

    <intent-filter>
        <action android:name="android.telecom.InCallService" />
    </intent-filter>
</service>
<uses-permission android:name="android.permission.WRITE_CONTACTS" />
<uses-permission android:name="android.permission.READ_CONTACTS" />
<uses-permission android:name="android.permission.CALL_PHONE" />
<uses-permission android:name="android.permission.READ_PHONE_STATE" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.MANAGE_OWN_CALLS" />
<uses-permission android:name="android.permission.READ_CALL_LOG" />
<uses-permission android:name="android.permission.FOREGROUND_SERVICE" />

此鏈接不是我的應用程序,但是此問題相同。

我最好建議在構造調用特定號碼的Intent時使用ACTION_DIAL而不是ACTION_CALL。 使用ACTION_DIAL,您將不需要在您的應用程序中擁有通話權限,因為ACTION_DIAL會使用已輸入的號碼打開撥號程序,並進一步允許用戶決定是實際撥打電話還是修改電話號碼,然后再撥打或根本不打電話。並檢查清單權限。

Intent intent = new Intent(Intent.ACTION_DIAL, Uri.parse("tel:" + "Your Phone_number"));// Initiates the Intent 
startActivity(intent);

問題解決了。

我的問題本身就是一個愚蠢的問題。

我以為不可能有兩個應用程序收到ACTION_CALL意圖。

某些設備安裝了可以處理ACTION_CALL的其他應用。

暫無
暫無

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

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