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]);
}
}
}
}
}