At the moment I ask the user about app features to save battery power:
public void startSessionClick(View view) {
String token = MyApp.getInstance().getPrefToken();
if (!TextUtils.isEmpty(token)) {
throw new RuntimeException("Token is not empty");
}
//todo hot-fix
if (checkBatteryOptimization()) {
Intent intent = new Intent(this, AuthEnterPhoneActivity.class);
startActivityForResult(intent, REQUEST_CODE_ENTER_PHONE);
} else {
String packageName = getApplicationContext().getPackageName();
Intent intent = new Intent();
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
intent.setAction(Settings.ACTION_REQUEST_IGNORE_BATTERY_OPTIMIZATIONS);
intent.setData(Uri.parse("package:" + packageName));
getApplicationContext().startActivity(intent);
//handleAnswer();
startSessionClick(null);
}
}
How to track the agreement or refusal of dialogue?
At the moment when the agreement I just open the next activity (checking before that the stock settings) and if the user refuses, then again show this dialog.
Track I need for that would be in the event of failure to display a dialog with explanations.