How do I avoid that my App enters optimization on Samsung devices

前端 未结 2 582
礼貌的吻别
礼貌的吻别 2020-12-08 08:39

Smart manager kills an app that hasn\'t been used for 3 days. My app does some background work and hence, the user doesn\'t need to open it.

What can I do so that it

2条回答
  •  [愿得一人]
    2020-12-08 09:32

    Sadly, there is currently no way to prevent this.

    The only thing you can do is instruct users to disable optimization for your app.

    I did some research about this myself not long ago, here are some links I saved that might be interesting for you

    https://news.samsung.com/global/smart-manager-the-way-to-keep-your-galaxy-smartphone-as-good-as-new-always

    http://developer.samsung.com/forum/thread/smart-manager-kills-my-alarms/202/288300?boardName=General&listLines=15&startId=zzzzz~&curPage=3

    http://developer.samsung.com/forum/thread/samsung-smart-manager-is-preventing-alarmmanager-to-work-correctly/201/288546?boardName=SDK&startId=zzzzz~&searchSubId=0000000001

    Also, here is a code snippet that launches the smart manager app's BatteryActivity (if it's installed) to help users to disable the optimization:

    Intent intent = new Intent();
    intent.setComponent(new ComponentName("com.samsung.android.sm", "com.samsung.android.sm.ui.battery.BatteryActivity"));
    try {
        getActivity().startActivity(intent);
    } catch (ActivityNotFoundException ex) {
        Toast.makeText(getActivity(), "Smart manager not installed on this device", Toast.LENGTH_LONG)
                .show();
    }
    

提交回复
热议问题