I have an SMS App where now in 6.0 the user have to allow the app to send SMS. Right now i have this code which i got from link here.
int MY_PERMISSIONS_REQUEST_READ_CONTACTS=0;
// Here, thisActivity is the current activity
if (ContextCompat.checkSelfPermission(this,
Manifest.permission.SEND_SMS)
!= PackageManager.PERMISSION_GRANTED) {
// Should we show an explanation?
if (ActivityCompat.shouldShowRequestPermissionRationale(this,
Manifest.permission.SEND_SMS)) {
// Show an expanation to the user *asynchronously* -- don't block
// this thread waiting for the user's response! After the user
// sees the explanation, try again to request the permission.
} else {
// No explanation needed, we can request the permission.
ActivityCompat.requestPermissions(this,
new String[]{Manifest.permission.SEND_SMS},
MY_PERMISSIONS_REQUEST_READ_CONTACTS);
// MY_PERMISSIONS_REQUEST_READ_CONTACTS is an
// app-defined int constant. The callback method gets the
// result of the request.
}
}
But when i deny acess (if the user accidently hit the button) everythings will pretty much make the app crash (Cause sms buttons wont work). So when the user starts/reboot the app after the user have denied access i would like the app to ask again. Right now when i tried on my emulator no dialog would come up again so i had to go to settings/app and set permission. Or uninstall and install again.