如何检测android.permission.USE_SIP



现在我的清单有一个严重的问题。我不知道为什么即使在清单中有了android.permission.USE_SIP之后,这也不被识别。我用这个代码来检测。

if (ContextCompat.checkSelfPermission(this, Manifest.permission.USE_SIP)
== PackageManager.PERMISSION_GRANTED) {
Toast.makeText(this, "la permission est donnée", Toast.LENGTH_SHORT).show();
} else {
Toast.makeText(this, "la permission est abscente", Toast.LENGTH_SHORT).show();
}

运行的是else子句。请帮我调试一下,谢谢。

这是我日志的一部分。

Process: com.example.boris.voipapp, PID: 19509
java.lang.SecurityException: Neither user 10105 nor current process has android.permission.USE_SIP.
at android.app.ContextImpl.enforce(ContextImpl.java:1600)
at android.app.ContextImpl.enforceCallingOrSelfPermission(ContextImpl.java:1632)

这是解决问题的代码的一部分

/** initialisation du SIP*/
if (ContextCompat.checkSelfPermission(this, Manifest.permission.USE_SIP)
== PackageManager.PERMISSION_GRANTED){
}else{
ActivityCompat.requestPermissions(this, new String[]{Manifest.permission.USE_SIP}, 0);
}

最新更新