How to know “Don't keep activities” is enabled in ICS?

后端 未结 7 704
遥遥无期
遥遥无期 2020-12-05 11:32

How to know in settings \"Don\'t keep activities\" option is enabled in ics via code. If it is in enabled,how to prevent the activity.

Note: I have used more activit

相关标签:
7条回答
  • 2020-12-05 12:20
        Settings.System.ALWAYS_FINISH_ACTIVITIES 
    

    now is deprecated so you should use

        Settings.Global.ALWAYS_FINISH_ACTIVITIES.equals("1")
    

    to check if this option is enabled

    update(thanks Aviv Ben Shabat comment):

    to handle all sdk versions I've created a method:

      public static boolean isFinishActivitiesOptionEnabled(Context context) {
        int result;
        if (Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN_MR1) {
            result = Settings.System.getInt(context.getContentResolver(), Settings.System.ALWAYS_FINISH_ACTIVITIES, 0);
        } else {
            result = Settings.Global.getInt(context.getContentResolver(), Settings.Global.ALWAYS_FINISH_ACTIVITIES, 0);
        }
    
        return result == 1;
    }
    
    0 讨论(0)
提交回复
热议问题