Most of Users are not devloper. For any reason, their devices are enabled for “Don’t keep activities”option in developer option.

if device is enabled, the activity manager will aggressively finish activities and
processes as soon as they are no longer needed. accordingly, some functions may not work.

The following code snippet shows how you can detect your app’s the option enabled

public boolean isAlwaysFinishActivitiesEnabled(){
    int state;
    
    if(Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN_MR1){
        state = Settings.System.getInt(
                getContentResolver(),
                Settings.System.ALWAYS_FINISH_ACTIVITIES,  
                0
        );
    }else{
        state = Settings.Global.getInt(
                getContentResolver(),
                Settings.Global.ALWAYS_FINISH_ACTIVITIES, 
                0
        );
    }
    return state != 0;
}
Buy me a coffeeBuy me a coffee
카테고리: Android

0개의 댓글

답글 남기기

이메일은 공개되지 않습니다.