I am developing my project in SDK version 23 where app permissions were newly introduced. In some guidelines they were using below code to read phone state permission is granted or not
if (ContextCompat.checkSelfPermission(serviceContext, Manifest.permission.READ_PHONE_STATE) == PackageManager.PERMISSION_GRANTED) {
//Read Phone state
}else{
}
But i am directly accessing checkSelfPermission
like below
if(serviceContext.checkSelfPermission(Manifest.permission.READ_PHONE_STATE) == PackageManager.PERMISSION_GRANTED) {
//Read Phone state
}else{
}
It's working fine. My question is what's the difference between above these codes?.which is the correct way to check for permission granted or not?