I have a code in android studio that asks the user, permission to use the phone service (to get the imei)
Well, my code is working perfectly, with a problem, when entering the page, a message is displayed if the permission was not conceived, until here, everything ok, but after the user accepts the permission, as I identify it was I accept and then yes, follow the code?
My code:
checkedPermission = ContextCompat.checkSelfPermission(getActivity(), Manifest.permission.READ_PHONE_STATE);
if (Build.VERSION.SDK_INT >= 23 && checkedPermission != PackageManager.PERMISSION_GRANTED) {
showMessageOKCancel("É nescesssario ter Acesso a Informaçoes do Aparelho Para Obter Melhor Desempenho!",
new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
requestPermissions(new String[] {Manifest.permission.READ_PHONE_STATE},
REQUEST_CODE_PHONE_STATE_READ);
}
});
return ;
} else
checkedPermission = PackageManager.PERMISSION_GRANTED;
After the user accepts the permission, my activity gets done, and only loads the information after I leave and enter it again, how would I solve this?