我想更改 Android 默认拨号器并想制作自己的自定义拨号器。为此,我选择了这个 GIthub repo作为启动项目。这适用于所有其他手机,并且停止在华为 p8 lite 上运行。默认弹出消息不会显示将应用程序设置为默认值。这是代码块
private fun checkDefaultDialer() {
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.M) return
val telecomManager = getSystemService(TELECOM_SERVICE) as TelecomManager
val isAlreadyDefaultDialer = packageName == telecomManager.defaultDialerPackage
if (isAlreadyDefaultDialer) return
val intent = Intent(TelecomManager.ACTION_CHANGE_DEFAULT_DIALER).putExtra(TelecomManager.EXTRA_CHANGE_DEFAULT_DIALER_PACKAGE_NAME, packageName)
startActivityForResult(intent, REQUEST_CODE_SET_DEFAULT_DIALER)
}
private fun checkSetDefaultDialerResult(resultCode: Int) {
val message = when (resultCode) {
RESULT_OK -> "User accepted request to become default dialer"
RESULT_CANCELED -> "User declined request to become default dialer"
else -> "Unexpected result code $resultCode"
}
Toast.makeText(this, message, Toast.LENGTH_SHORT).show()
}
StertActivityforResult
返回RESULT_CANCELED
和消息
User declined request to become default dialer
找不到任何解决方案。任何帮助将不胜感激。