Search code examples
androidandroid-manifestandroid-permissionssip-servervoip-android

How to detect android.permission.USE_SIP


Now I have a serious problem with my manifest. I don't know why even after had android.permission.USE_SIP in manifest, this is not recognized. I use this code to detect.

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();
}

And it is the clause else that is run. Please help me to debug this, thank you.

This is a part of my 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)

Solution

  • this is a part of code that that resolve the problem

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