{"id":26886,"date":"2019-11-06T13:01:56","date_gmt":"2019-11-06T04:01:56","guid":{"rendered":"https:\/\/www.charlezz.com\/?p=26886"},"modified":"2019-11-06T13:01:56","modified_gmt":"2019-11-06T04:01:56","slug":"how-to-detect-if-dont-keep-activities-is-enabled","status":"publish","type":"post","link":"https:\/\/charlezz.com\/?p=26886","title":{"rendered":"How to detect if &#8220;Don&#8217;t keep activities&#8221; is\u00a0Enabled"},"content":{"rendered":"<p name=\"2f49\" class=\"graf graf--p\">Most of Users are not devloper. For any reason, their devices are enabled for \u201cDon\u2019t keep activities\u201doption in developer option.<\/p>\n<p name=\"e297\" class=\"graf graf--p\">if device is enabled, the activity manager will aggressively finish activities and<br \/>\nprocesses as soon as they are no longer needed. accordingly, some functions may not work.<\/p>\n<p name=\"788b\" class=\"graf graf--p\">The following code snippet shows how you can detect your app\u2019s the option enabled<\/p>\n<pre name=\"c356\" class=\"graf graf--pre\">public boolean isAlwaysFinishActivitiesEnabled(){\r\n    int state;\r\n    \r\n    if(Build.VERSION.<em class=\"markup--em markup--pre-em\">SDK_INT <\/em>&lt; Build.VERSION_CODES.<em class=\"markup--em markup--pre-em\">JELLY_BEAN_MR1<\/em>){\r\n        state = Settings.System.<em class=\"markup--em markup--pre-em\">getInt<\/em>(\r\n                getContentResolver(),\r\n                Settings.System.<em class=\"markup--em markup--pre-em\">ALWAYS_FINISH_ACTIVITIES<\/em>,  \r\n                0\r\n        );\r\n    }else{\r\n        state = Settings.Global.<em class=\"markup--em markup--pre-em\">getInt<\/em>(\r\n                getContentResolver(),\r\n                Settings.Global.<em class=\"markup--em markup--pre-em\">ALWAYS_FINISH_ACTIVITIES<\/em>, \r\n                0\r\n        );\r\n    }\r\n    return state != 0;\r\n}<\/pre>\n<figure name=\"68dd\" class=\"graf graf--figure\"><img decoding=\"async\" class=\"graf-image\" data-image-id=\"1*m51ffi1rmX8m7kHE7GRO3A.gif\" data-width=\"533\" data-height=\"300\" data-is-featured=\"true\" src=\"https:\/\/cdn-images-1.medium.com\/max\/1600\/1*m51ffi1rmX8m7kHE7GRO3A.gif\" \/><\/figure>\n","protected":false},"excerpt":{"rendered":"<p>Most of Users are not devloper. For any reason, their devices are enabled for \u201cDon\u2019t keep activities\u201doption 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 [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"om_disable_all_campaigns":false,"inline_featured_image":false,"_monsterinsights_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0},"categories":[16],"tags":[],"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/charlezz.com\/index.php?rest_route=\/wp\/v2\/posts\/26886"}],"collection":[{"href":"https:\/\/charlezz.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/charlezz.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/charlezz.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/charlezz.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=26886"}],"version-history":[{"count":1,"href":"https:\/\/charlezz.com\/index.php?rest_route=\/wp\/v2\/posts\/26886\/revisions"}],"predecessor-version":[{"id":26887,"href":"https:\/\/charlezz.com\/index.php?rest_route=\/wp\/v2\/posts\/26886\/revisions\/26887"}],"wp:attachment":[{"href":"https:\/\/charlezz.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=26886"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/charlezz.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=26886"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/charlezz.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=26886"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}