Android Phone Process cleanup

Source: Internet
Author: User

One in the phone Settings \ Program Management end Process Good trouble, also do not want to install app management software because of this, rather than write a script a button clean

This script to the phone root (mainly put the file into the \system\bin, and set to executable, not root can not use the CHOMD command)

ADB Debugging Tools, online a lot, can download

Say the idea

    1. Gets the package name of the process (because the package name is more readable than ppid)
    2. Generate a file containing the process to end
    3. Write all the processes you want to end into scripts, put them on your phone and set them to run
    4. The phone executes the script directly

Good, hands-on link

First use the command adb shell PS >c:\app.txt to get the process and package name, and write to the app.txt text in the C drive.

The meaning of each field:

User Process Current Users

PID Process ID

PPID Parent Process ID

Vsize the virtual memory size of the process, in kilobytes

The amount of memory that is actually consumed by RSS, in kilobytes

Wchan the name of the kernel function in which the process is sleeping;

PC program Counter

Name process status and names

You can use the command adb shell am force-stop package name to end the process, such as the Cool music box. It is

ADB shell am force-stop cn.kuwo.player

Separate the package name from App.txt, here I use the Python script, get the package name Com.xxx.xxx and cn.xxx.xxx (most of the Android programs in China use these two)

The Python code is as follows arry.py

1 #Coding=utf-82 ImportOS3 ImportMath4 5prefix ="echo-e am Force-stop"6Perfixendfirst =">/system/bin/d"7Perfixend =">>/system/bin/d"8Resultarr =[]9Resultstr=""Ten  OneF=open ('App.txt','R') As=F.readlines () - #count = Len (s) -  the  forTinchRange (1, Len (s)): -str = s[t-0] -     ifstr! = None and  "S" inchStr: -Strsname = Str.split ("S")     +         ifSTRSNAME[1]! =None: -StrName = Strsname[1].replace ("S","") +             ifStrname.startswith ("com.")orStrname.startswith ("CN."): A                 #Insert Array atResultarr.insert (0,strname.strip ('\ n')) -                 Print(StrName) -  -  - #resultstr = resultstr + "echo" + "#!/system/bin/sh" + Perfixendfirst + "\ n " -  forRinchResultarr: inResultStr = resultstr + prefix + r+ perfixend+"\ n"  -  toResultStr = ResultStr +'echo-e "Echo success!" >>/system/bin/d'  +With open ("d.sh","W") as F: - f.write (RESULTSTR) the  *Os.system ('Pause')
View Code

Generate a file called "d.sh" in its directory (d is the first letter of the Delete)

We can open the d.sh file in Notepad with the result as follows

Here, I use echo to write the string to the phone's/system/bin/d file, rather than push the file to the phone, do not know why the garbled and can not be wrapped (inconvenient to read and maintain)

You can copy all of the s.sh to the sticker, open an ADB debug window and take the power to root, then paste

Then set file D to executable chmod 777/system/bin/d

You can then invoke the script under a normal user,

Success! to run the end of the meeting Tips

On the phone with the "terminal Emulator", call to Su, do not mention the right will be wrong, the individual has not yet figured out why

Clear the background with ease.

If you later add another package name to Weibo, you can write

Echo-e am force-stop com.sina.weibo >>/system/bin/d.

Android Phone Process cleanup

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.