Friday, April 12, 2013

[android help] How to know "Don't keep activities" is enabled in ICS?


I agree with @Kaediil that android applications must work well while "Don't keep activities" option is checked.


Bu for some reason if you have to check "alwaysFinishActivities" value you can use code below;



/**
* returns true if AlwaysFinishActivities option is enabled/checked
*/
private boolean isAlwaysFinishActivitiesOptionEnabled() {
int alwaysFinishActivitiesInt = 0;
if (Build.VERSION.SDK_INT >= 17) {
alwaysFinishActivitiesInt = Settings.System.getInt(getApplicationContext().getContentResolver(), Settings.Global.ALWAYS_FINISH_ACTIVITIES, 0);
} else {
alwaysFinishActivitiesInt = Settings.System.getInt(getApplicationContext().getContentResolver(), Settings.System.ALWAYS_FINISH_ACTIVITIES, 0);
}

if (alwaysFinishActivitiesInt == 1) {
return true;
} else {
return false;
}
}


If alwaysFinishActivities option is checked and you want it to be unchecked;


You can direct user to "Settings -> Developer options" to uncheck that value. (This is better than to get extra scary permissions and set this value programatically)



/**
* shows Settings -> Developer options screen
*/
private void showDeveloperOptionsScreen(){
Intent intent = new Intent(android.provider.Settings.ACTION_APPLICATION_DEVELOPMENT_SETTINGS);
intent.setFlags(Intent.FLAG_ACTIVITY_NO_HISTORY);
startActivity(intent);
}


.

stackoverflow.comm

No comments:

Post a Comment

Google Voice on T-Mobile? [General]

Google Voice on T-Mobile? So I recently switched from a GNex on Verizon to a Moto X DE on T-Mobile. I had always used Google Voice for my v...