Skip to content

Commit

Permalink
linkedin#81 API check for "always finish activities" state.
Browse files Browse the repository at this point in the history
  • Loading branch information
Marc Kurtz committed Aug 30, 2018
1 parent 621c517 commit 43a812b
Showing 1 changed file with 12 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@

import android.annotation.SuppressLint;
import android.content.ContentResolver;
import android.os.Build;
import android.provider.Settings;
import android.support.annotation.NonNull;
import android.util.Log;
Expand Down Expand Up @@ -54,12 +55,20 @@ void restoreAlwaysFinishActivitiesState(@NonNull ContentResolver contentResolver
* @return true if the new value was set, false on database errors
*/
boolean setAlwaysFinishActivitiesState(@NonNull ContentResolver contentResolver, boolean value) {
return Settings.Global.putInt(contentResolver, Settings.Global.ALWAYS_FINISH_ACTIVITIES, value ? 1 : 0);
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN_MR1) {
return Settings.System.putInt(contentResolver, Settings.System.ALWAYS_FINISH_ACTIVITIES, value ? 1 : 0);
} else {
return Settings.Global.putInt(contentResolver, Settings.Global.ALWAYS_FINISH_ACTIVITIES, value ? 1 : 0);
}
}

public static boolean getAlwaysFinishActivitiesState(@NonNull ContentResolver contentResolver) {
private boolean getAlwaysFinishActivitiesState(@NonNull ContentResolver contentResolver) {
try {
return Settings.Global.getInt(contentResolver, Settings.Global.ALWAYS_FINISH_ACTIVITIES) != 0;
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN_MR1) {
return Settings.System.getInt(contentResolver, Settings.System.ALWAYS_FINISH_ACTIVITIES) != 0;
} else {
return Settings.Global.getInt(contentResolver, Settings.Global.ALWAYS_FINISH_ACTIVITIES) != 0;
}
} catch (Settings.SettingNotFoundException e) {
Log.e(TAG, "Error reading always finish activities settings!", e);
return false;
Expand Down

0 comments on commit 43a812b

Please sign in to comment.