【发布时间】:2021-01-19 15:00:55
【问题描述】:
我有下面给定的代码为我提供了一个自我管理的连接服务。但这已停止处理此错误:
java.lang.SecurityException: 这个PhoneAccountHandle 没有为这个用户启用!
代码:
class CallManager(context: Context) {
val telecomManager: TelecomManager
var phoneAccountHandle: PhoneAccountHandle
var context: Context
init {
telecomManager = context.getSystemService(Context.TELECOM_SERVICE) as TelecomManager
this.context = context
val componentName = ComponentName(this.context, ConnService::class.java)
phoneAccountHandle = PhoneAccountHandle(componentName,"com.darkhorse.videocalltest")
}
fun register(){
val phoneAccount = PhoneAccount.builder(phoneAccountHandle,"com.darkhorse.videocalltest")
.setCapabilities(PhoneAccount.CAPABILITY_CALL_PROVIDER) .setCapabilities(PhoneAccount.CAPABILITY_CONNECTION_MANAGER).build()
telecomManager.registerPhoneAccount(phoneAccount)
}
fun incomingCall(caller: String?){
val callInfo = Bundle()
callInfo.putString("from", caller)
telecomManager.addNewIncomingCall(phoneAccountHandle,callInfo)
Log.i("incomingCall", "incomingCall")
}
}
我确信之前的代码运行良好。
This question 没有帮助。
【问题讨论】:
-
有同样的问题。你找到解决办法了吗?