Remove unwanted programs from your Android system by yourself

Source: Internet
Author: User

Remove unwanted programs from your Android system by yourself

Chenyue PK.

2014/6/29

Recently when using my NEXUS7, always inexplicably pop up some ad popup, also automatically download some applications, but also on the desktop to generate a "wonderful app" icon, the shortcut associated with the program display content and advertising content is consistent, it is annoying, Use 360 mobile phone defender and Le security can not find this bad program, so do it yourself to clear this program.

Since the Nexus 7 is usually used for testing programs, the installation of a lot of applications, manually deleted some suspicious applications later or not, speculation is that some apps may have been tampered with, no longer to remove the app, and turn to the desktop shortcut.

Now that you have created the "wonderful app" icon and clicked to start the program, there is no intuitive link between the shortcuts and apps for Android, which requires writing some code to solve:

1. Get the package name corresponding to the shortcut

The cycle, each Android app relies on a unique package name on the line to distinguish, as long as you can find the package name, the rest is simple.

Getting shortcuts requires permission to read and write system settings:

<uses-permissionandroid:name= "Com.android.launcher.permission.READ_SETTINGS"/>

<uses-permissionandroid:name= "Com.android.launcher.permission.WRITE_SETTINGS"/>

The code to read the shortcut is as follows:

/**

* Show shortcut information

* @param Context Object

*/

publicstatic void Printshortcutinfo (context context) {

try{

Contentresolverresolver = Context.getcontentresolver ();

cursor cursor = resolver.query (Uri.parse ("content://com.android.launcher2.settings/favorites?notify=true"), NULL, Null,null,null);

int index = 0;

while (Cursor.movetonext ()) {

Intnum = 5;

try{

Stringinfo = "";

for (Inti = 0;i < num;i++) {

info+= cursor.getstring (i) + ",";

}

System.out.println (index+++ "" + info);

}catch (Exceptione1) {}

}

Cursor.close ();

}catch (Exceptione) {

E.printstacktrace ();

}

}

By executing these code, found "Wonderful application" this shortcut corresponding to the package name is "Cn.com.hkgt.gasapp", through the package name can not directly find the corresponding program, the following code to uninstall the program, to see exactly where the problem.

2. Uninstall the app according to the package name

For a program without root, uninstalling just calls the uninstall interface, but this is enough for me.

Permissions required to uninstall the program:

<uses-permissionandroid:name= "Android.permission.DELETE_PACKAGES"/>

Method code for uninstalling the program:

/**

* Uninstall software

* @param Context Object

* @param pkgname Package Name

*/

public static void Deletepackage (Contextcontext,string pkgname) {

try{

Uri Packageuri =uri.parse ("package:" + pkgname);

Intent uninstallintent = newintent (Intent.action_delete, Packageuri);

Context.startactivity (uninstallintent);

}catch (Exception e) {

E.printstacktrace ();

}

}

The implementation of this method to unload the name of the program, finally found that the Sinopec Business Hall program was tampered with, uninstall the app, go to their official website to download and install the app again, the world finally a quiet.

Finally found that Baidu Application Center and the application Bao inside the Sinopec Business Hall procedures are tampered with the program, it seems that later download and install the app is a little more careful good.

To share this little experience with all of you, if you have a better way also please tell me, thank you. Contact information: [Email protected]

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.