Android Desktop hover clear Memory app Overview

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.