Today, nothing to write a clear memory of a small thing, similar to 360, hovering on the desktop, after clicking to clear the background useless program, clear daemon is by calling Activitymanger. killbackgroundprocesses Way to do this, there is a bad place in this way, is the importance of the high level of application can not be killed. The key code is shown below
1 Activitymanager mactivitymanager = Mymanager.getactivitymanager (Mcontext); 2 list<activitymanager.runningappprocessinfo> process = Mactivitymanager.getrunningappprocesses (); 3 4 for (int i=0;i<process.size (); i++) {5 activitymanager.runningappprocessinfo ar = process.get (i); 6 String packagename = ar.processname; 7 packagename = Packagename.split (":") [0]; 8 //important level is greater than 200, and untrusted background will be killed 9 if (ar.importance>100 &&!) Mymanager.istrust (PackageName)) { Mymanager.getactivitymanager (mcontext). Killbackgroundprocesses ( PackageName); }12 }
Another part of the function is that the desktop is suspended, this feature is added to the desktop by Windowmanger objects, the key code is shown below
1 WindowManager windowmanager = Getwindowmanager (context); 2 int screenwidth = Windowmanager.getdefaultdisplay (). GetWidth (); 3 int screenheight = Windowmanager.getdefaultdisplay (). GetHeight (); 4 5 if (msmallfloatwin==null) {6 Msmallfloatwin = new Smallfloatwin (context); 7 if (SMALLW Indowparams = = null) {8 smallwindowparams = new Layoutparams (); 9 Smallwindowparams.type = Layoutparams.type_phone; Ten smallwindowparams.format = pixelformat.rgba_8888; Smallwindowparams.flags = Layoutparams.flag_not_touch_modal 12 | layoutparams.flag_not_focusable; smallwindowparams.gravity = Gravity.left | Gravity.top; Smallwindowparams.width = Smallfloatwin.viewwidth; Smallwindowparams.height = Smallfloatwin.viewheight; Smallwindowparams.x = ScreenWidth; SmallwIndowparams.y = SCREENHEIGHT/2; Msmallfloatwin.setparams (Smallwindowparams), Windowmanager.addview (MSMALLFL Oatwin, Smallwindowparams); 21}
Android Desktop hover clear Memory app Overview