Manually clear undesirable programs in the Android system

Source: Internet
Author: User

Manually clear undesirable programs in the Android system

Chen yuefeng

 

Recently, when using Nexus7, some advertisement pop-up windows are often displayed inexplicably, some applications are automatically downloaded, and an icon called "wonderful application" is generated on the desktop, the content displayed by the program associated with this shortcut is the same as the content of the advertisement. It is annoying to use 360 mobile guard and happy security to find this program, so we can clear the program by ourselves.

Due to the fact that Nexus 7 is usually used for testing programs, there are many installed applications. It still does not work after some suspicious applications are manually deleted. It is assumed that some apps may have been tampered, the app is no longer deleted, but the desktop shortcut is turned.

Since the "wonderful application" icon is generated and you can click it to start the program, there is no intuitive connection between the android shortcuts and the app, in this case, you need to write some code to solve the problem:

1. Get the package name corresponding to the shortcut

Every Android app depends on a unique package name in a public cycle. It is easy to find this package name.

To obtain shortcuts, you need to read and write the permissions set by the system:

<Uses-permissionandroid: name = "com. android. launcher. permission. READ_SETTINGS"/>

<Uses-permissionandroid: name = "com. android. launcher. permission. WRITE_SETTINGS"/>

The code for reading shortcuts is as follows:

/**

* Display shortcuts

* @ Param context object

*/

Publicstatic void printShortcutInfo (Context context ){

Try {

ContentResolverresolver = context. getContentResolver ();

Cursor cursor = resolver. query (Uri. parse ("content: // com. android. launcher2.settings/favorites? Optional Y = true "), 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 (effectione ){

E. printStackTrace ();

}

}

By executing the code, we found that the package name corresponding to the "wonderful application" shortcut is "cn.com. hkgt. the corresponding program cannot be directly found through the package name. Then we will encode and uninstall the program to see what went wrong.

2. Uninstall the app Based on the package name

For programs without root, only the uninstall interface is called during uninstallation, but this is enough for me.

Permissions required to uninstall a program:

<Uses-permissionandroid: name = "android. permission. DELETE_PACKAGES"/>

Method Code for uninstalling a 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 ();

}

}

When I uninstalled the program with the name of the bread, I finally found that the program in the Sinopec business office was tampered with. I uninstalled the app and went to their official website to download and install the app again, the world is finally quiet.

Finally, we found that the Sinopec Business Hall programs provided by Baidu Application Center and app Bao are all tampered with. It seems that it is better to download and install apps in the future.

Share your experience in this short article with you. If you have any better methods, please let me know. Thank you. Contact: cqucyf@JavaMeStudio.com

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.