3

Is there a way to stop/clear a cached background process of my Android Widget?

My widget uses less RAM memory (about 1 mb) but a lot of memory in background cache process (about 100/200 mb).

Is there a way to stop the background cache process or clear it?

krsteeve
  • 1,794
  • 4
  • 19
  • 29
Meroelyth
  • 5,310
  • 9
  • 42
  • 52

3 Answers3

2

Settings > Developer Options > Applications > Background Process: No.

PS. Don't settle anything less than a complete solution!

wichoxp
  • 21
  • 2
1

I think CommonsWare's answer on On Android, what's the difference between running processes and cached background processes? might be helpful to you. In short, it seems that there is no reason to clear it. Moreover, if you click on the process, you will see a message "This is an old application process that is being kept for better speed in case it is needed again. There is usually no reason to stop it." Hope that helps.

Community
  • 1
  • 1
hjchin
  • 864
  • 2
  • 8
  • 25
0

I think there is often a reason to clear the memory on Android. When you go on-line, Android (actually Google) preloads a bunch of apps as "cached". When you go off-line, it clears those and loads a bunch more. And then there are things like Google+ that just sits there hogging 50Mb of your poor phone's RAM. So if you need to remove all that unused metadata-gathering nonsense so that your app has some space, you could do something like this:

public void clearMem() {
    ActivityManager amgr = (ActivityManager) this.getSystemService(Context.ACTIVITY_SERVICE);
    List<ActivityManager.RunningAppProcessInfo> list = amgr.getRunningAppProcesses();
    if (list != null){
        for (int i = 0; i < list.size(); i++) {
            ActivityManager.RunningAppProcessInfo apinfo = list.get(i);

            String[] pkgList = apinfo.pkgList;
            if ((! apinfo.processName.startsWith("com.sec")) && ((apinfo.importance > 150) || (apinfo.processName.contains("google")))) {
                for (int j = 0; j < pkgList.length; j++) {
                    amgr.killBackgroundProcesses(pkgList[j]);
                }
            }
        }
    }
}
SBotirov
  • 13,872
  • 7
  • 59
  • 81
R Earle Harris
  • 985
  • 9
  • 17