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 doesn't enter app optimization mode ( Android OS 5.0.2, 5.1.1)
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
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();
}
I found an array with the packages that are in the whitelist from Smart Manager. There is some kind of partnership with developers and Samsung.
Galaxy S7 Android N, Smart Manager its package name now is "com.samsung.android.lool"
Intent intent = new Intent(Intent.ACTION_MAIN);
intent.setClassName("com.samsung.android.lool", "com.samsung.android.sm.ui.battery.BatteryActivity");
intent.addCategory(Intent.CATEGORY_LAUNCHER);
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
startActivity(intent);
<string-array name="exclude_from_spcm">
<item>com.sds.mdmain</item>
<item>com.whatsapp</item>
<item>com.facebook.orca</item>
<item>com.tencent.mm</item>
<item>com.skype.raider</item>
<item>com.viber.voip</item>
<item>jp.naver.line.android</item>
<item>com.kakao.talk</item>
<item>com.snapchat.android</item>
<item>com.sgiggle.production</item>
<item>kik.android</item>
<item>com.kakao.story</item>
<item>com.nhn.android.band</item>
<item>com.btb.minihompy</item>
<item>com.sec.chatonblue</item>
<item>com.sds.mobiledesk</item>
<item>com.samsung.android.spay</item>
<item>com.sec.android.app.shealth</item>
<item>com.z7.samsung.mobiledesk.z7</item>
<item>com.z7.samsung.mobiledesk.Z7</item>
<item>com.sds.mysinglesquare</item>
<item>com.samsung.uready.agent</item>
<item>com.sds.mobile.mdm.client.MDMManager</item>
<item>com.samsung.android.app.watchmanager</item>
<item>com.samsung.android.wms</item>
<item>com.samsung.accessory.goproviders</item>
<item>com.samsung.accessory.saproviders</item>
<item>com.sec.android.sidesync30</item>
<item>com.amc.ui</item>
<item>com.sec.wecontacts</item>
<item>com.bns.wecontacts</item>
<item>com.sec.weagent</item>
<item>com.sec.wetester</item>
<item>com.samsung.dbs.service</item>
<item>com.kddi.android.videopass</item>
<item>com.ktcs.whowho</item>
<item>com.google.android.wearable.app</item>
<item>com.google.android.projection.gearhead</item>
<item>com.sec.chaton.secure</item>
<item>com.estsoft.alyac</item>
<item>com.estsoft.alyac.tablet</item>
<item>com.coremobility.app.vnotes</item>
<item>com.kineto.smartwifi</item>
<item>msgplus.jibe.sca</item>
<item>com.locationlabs.sparkle.yellow.pre</item>
<item>com.locationlabs.v3client</item>
<item>com.oem.smartwifisupport</item>
<item>com.wsandroid.suite.vodaemea</item>
<item>com.vodafone.sn.vpn</item>
<item>com.vodafone.smhs</item>
<item>com.vodafone.vodafone360updates</item>
<item>com.vodafone.netperform.full</item>
<item>com.vf_nqt.client</item>
<item>com.vodafone.messaging</item>
<item>com.vodafone.safetynet.core</item>
<item>at.mobilkom.android.meina1</item>
<item>al.myvodafone.android</item>
<item>com.zentity.vodafone</item>
<item>com.appseleration.android.selfcare</item>
<item>com.myvodafone.android</item>
<item>hu.mito.android.vodafone</item>
<item>com.VodafoneIreland.MyVodafone</item>
<item>it.vodafone.my190</item>
<item>com.vodafone.android</item>
<item>com.vodafone.mCare</item>
<item>be.belgacom.hello</item>
<item>ro.vodafone.mcare.android</item>
<item>es.vodafone.mobile.mivodafone</item>
<item>com.swisscom.myswisscom</item>
<item>com.myvodafoneapp</item>
<item>za.co.vodacom.android.app</item>
<item>com.appseleration.speedtest</item>
<item>com.radioopt.tmplus</item>
<item>com.radioopt.widget</item>
<item>com.radioopt.engineering</item>
<item>com.radioopt.enterprise</item>
<item>com.radioopt.apc</item>
<item>com.radioopt.network</item>
<item>com.vodafone.accesorystore</item>
<item>at.mobilkom.android.a1apps</item>
<item>com.vodafone.myaccessories</item>
<item>com.swisscom.scappslauncher</item>
<item>com.vodafone.directaccessories</item>
<item>hr.infinum.mojvip</item>
<item>com.vodafone.appstore.sa</item>
<item>com.skt.skaf.a000as00tm</item>
<item>com.kt.mtmoney</item>
<item>com.lgt.tmoney</item>
<item>com.ebcard.skcashbee</item>
<item>com.kt.cashbee</item>
<item>com.lguplus.cashbee</item>
<item>com.hs.govsns.mobile</item>
<item>com.oculus.home</item>
<item>com.samsung.android.hmt.vrsvc</item>
<item>com.oculus.oculus360photos</item>
<item>com.oculus.oculus360videos</item>
<item>com.samsung.android.app.vrsetupwizard</item>
<item>com.samsung.android.app.vrsetupwizardstub</item>
<item>com.oculus.horizon</item>
<item>com.samsung.android.app.vr.gallery</item>
<item>com.samsung.android.app.vr.video</item>
<item>com.oculus.cinema</item>
<item>com.oculus.systemactivities</item>
<item>com.facebook.appmanager</item>
<item>com.facebook.system</item>
<item>com.ipg.gguide.dcm_app.android</item>
<item>com.ipg.gguide.dcm_wifi_app.android</item>
<item>com.nttdocomo.android.iconcier</item>
<item>jp.co.nttdocomo.ichannel</item>
<item>com.nttdocomo.android.osv</item>
<item>com.nttdocomo.android.anmane</item>
<item>com.nttdocomo.android.anmane2</item>
<item>com.rsupport.rs.activity.ntt</item>
<item>jp.co.nttdocomo.android.gs.utility2_sha2</item>
<item>jp.co.nttdocomo.android.gs.utility2</item>
<item>com.nttdocomo.android.mascot</item>
<item>com.nttdocomo.android.docomosimplehome</item>
<item>com.nttdocomo.android.lac</item>
<item>com.nttdocomo.android.settings.lac</item>
<item>com.nttdocomo.android.cloudstorageservice</item>
<item>com.mcafee.vsm_android_dcm</item>
<item>com.nttdocomo.android.gs.utility_sha2</item>
<item>com.nttdocomo.android.gs.utility</item>
<item>com.nttdocomo.android.accountwipe</item>
<item>com.nttdocomo.android.messagedl</item>
<item>com.nttdocomo.android.homeagent</item>
<item>com.nttdocomo.android.toruca</item>
<item>com.nttdocomo.android.photocollection</item>
<item>com.nttdocomo.android.photoviewer</item>
<item>jp.id_credit_sp.android</item>
<item>com.nttdocomo.android.apnmng</item>
<item>jp.co.nttdocomo.contentsheadline</item>
<item>com.mcafee.safecall.docomo</item>
<item>jp.dmapnavi.navi02</item>
<item>com.uievolution.gguide.android</item>
<item>com.showcasegig.devlawson</item>
<item>jp.co.mcdonalds.android</item>
<item>jp.co.lawson.activity</item>
<item>kr.co.nexdigm.mdm.s</item>
<item>kr.co.nexdigm.mdm.agent</item>
<item>com.sktelecom.ssm</item>
<item>com.sktelecom.ssmpush</item>
<item>com.ebcard.cashbeew.s</item>
<item>com.life360.android.safetymapd</item>
<item>com.fsp.android.friendlocator</item>
<item>com.fsp.android.c</item>
<item>com.fsp.android.h</item>
<item>com.fsp.android.phonetracker</item>
<item>com.life360.android.note4</item>
<item>com.life360.android.s6</item>
<item>fr.freemobile.android.vvm</item>
<item>fr.freemobile.android.mobilecompagnon</item>
<item>kr.co.bnkbank.push.customer</item>
<item>kr.co.bnkbank.push.employee</item>
<item>com.shinhan.sbanking</item>
<item>com.shinhan.speedup</item>
<item>com.shinhan.smartcaremgr</item>
<item>com.shinhan.smartfund</item>
<item>com.shinhan.missionbanking</item>
<item>com.shinhan.mobilebankbook</item>
<item>com.safeon.approval</item>
<item>com.shinhan.sbizbank</item>
<item>com.shinhan.trade.copper</item>
<item>com.shinhan.dingdong</item>
<item>com.shinhan.shb2chd</item>
<item>com.shcard.smartpay</item>
<item>com.shinhancard.smartshinhan</item>
<item>com.shinhancard.smartshinhan.mini</item>
<item>com.wr.alrim</item>
<item>com.IBK.SmartPush.app</item>
<item>com.hanafn.push.agent</item>
<item>com.hanabank.ebk.channel.android.hananbank</item>
<item>com.samsung.android.app.memo</item>
<item>com.samsung.android.snote</item>
<item>com.samsung.android.app.pinboard</item>
<item>com.sds.mobile.mdm.client.MDMManager</item>
<item>com.sds.emm.client</item>
<item>com.sds.emm.client.visitor</item>
<item>gogolook.callgogolook2</item>
<item>com.nhn.android.webtoon</item>
<item>com.naver.linewebtoon</item>
<item>com.naver.vapp</item>
<item>com.navercorp.android.ttsapp</item>
<item>com.nhn.android.music</item>
<item>net.daum.android.daum</item>
<item>com.daumkakao.android.brunchapp</item>
<item>com.kakao.page</item>
<item>com.vaultmicro.kidsnote</item>
<item>com.orange.vvm</item>
<item>com.telenor.mbedriftsnett</item>
<item>com.samsung.android.app.scharm</item>
<item>net.ib.android.smcard</item>
<item>com.samsungcard.certi</item>
<item>kr.co.samsungcard.mpocket</item>
<item>com.samsungcard.shopping</item>
<item>com.samsungcard.baby</item>
<item>sc.chn.hom.msa.ga</item>
<item>com.samsung.android.email.provider</item>
<item>com.samsung.oh</item>
<item>com.sec.android.app.sbrowser</item>
<item>com.microsoft.windowsintune.companyportal</item>
<item>com.icq.mobile.client</item>
<item>com.my.mail</item>
<item>com.vkontakte.android</item>
<item>ru.mail.mailapp</item>
<item>ru.ok.android</item>
<item>com.google.android.apps.tachyon</item>
<item>ru.mail</item>
<item>com.lacoon.security.fox</item>
<item>com.google.android.apps.fireball</item>
<item>com.sds.mms.ui</item>
<item>com.mcafee.android.scanservice</item>
<item>com.android.services.telephony.common</item>
<item>com.samsungcard.android.oap</item>
<item>com.sec.android.app.ocr3</item>
<item>com.sec.android.app.ocr4</item>
<item>com.mediatek.BlueMagpie</item>
<item>com.samsung.android.game.gametools</item>
<item>it.h3g.areaclienti3</item>
<item>com.skt.prod.cloud</item>
<item>com.turkcell.bip</item>
<item>com.samsung.android.intelligence.executormanager</item>
<item>com.nttdocomo.android.hcebridge</item>
<item>jp.id_credit_sp.android.devappli</item>
<item>com.knb.psb</item>
<item>com.knb.csb</item>
<item>com.knb.bsp</item>
<item>com.knb.bdr</item>
<item>com.diotek.sec.lookup.dictionary</item>
<item>com.samsung.android.onlinevideo</item>
<item>com.oculus.systemdriver</item>
<item>com.oculus.gearchina</item>
<item>com.oculus.systemservices</item>
<item>com.nttdocomo.android.iconcier_contents</item>
<item>com.nttdocomo.android.socialphonebook</item>
<item>com.nttdocomo.android.portablesim</item>
<item>com.sktelecom.ttalk</item>
</string-array>
来源:https://stackoverflow.com/questions/37205106/how-do-i-avoid-that-my-app-enters-optimization-on-samsung-devices