如何检测android.permission.USE_SIP

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

这是我的一部分 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)

这是解决问题的部分代码

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