1

现在我的清单有一个严重的问题。我不知道为什么即使android.permission.USE_SIP在 manifest 之后,也无法识别。我使用此代码进行检测。

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 子句。请帮我调试一下,谢谢。

这是我的 logcat 的一部分。

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)
4

1 回答 1

2

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

/** 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);
       }

于 2018-12-11T14:37:13.377 回答