簡體   English   中英

如何為 Andoid<=28 實現 CallScreeningService

[英]How to implement CallScreeningService for Andoid<=28

**到目前為止我做了什么:**

我已經為 Android SDK 29 實現了它

 RoleManager roleManager = (RoleManager) getSystemService(ROLE_SERVICE);
 Intent intent = roleManager.createRequestRoleIntent(RoleManager.ROLE_CALL_SCREENING);
 startActivityForResult(intent, REQUEST_ID1);

**我在找什么? : **

我想為 < SDK 29 的設備實施呼叫篩選服務。如果有人以前做過,請幫助我。

不幸的是,你不能。

It is impossible to access the RoleManager class on Android versions < 29 because this class was introduced on Android 29. Therefore, you can only use this class on devices running Android 29 and up.

對於 Android <= 28,要綁定 CallScreeningService 應用程序必須設置為默認撥號應用程序。 在運行時,可以顯示一個對話框,要求用戶將您的應用程序設置為默認撥號器應用程序,如下所示:

if (getSystemService(TelecomManager.class).getDefaultDialerPackage() != getPackageName()) {
                    Intent changedDialer= new Intent(TelecomManager.ACTION_CHANGE_DEFAULT_DIALER);
                    changedDialer.putExtra(TelecomManager.EXTRA_CHANGE_DEFAULT_DIALER_PACKAGE_NAME, getPackageName());
                    startActivity(ChangeDialer);
      }

暫無
暫無

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

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