if (Build.VERSION.SDK_INT >= 23) {
if (!Settings.canDrawOverlays(getActivity())) {
try {
Intent intent = new Intent(Settings.ACTION_MANAGE_OVERLAY_PERMISSION,
Uri.parse("package:" + getActivity().getPackageName()));
startActivityForResult(intent, 10);
} catch (Exception e) {
e.printStackTrace();
}
} else {
checkCredit();
}
} else {
checkCredit();
}
@RequiresApi(api = Build.VERSION_CODES.M)
@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
if (requestCode == 10) {
if (Settings.canDrawOverlays(getActivity())) {
checkCredit();
}
}
}