Android apk listener

Source: Internet
Author: User

Android apk listener

Android apk installation, data cleanup, forced stop, and uninstall listening

 

No nonsense, Code on

 

 

             
                                                                                                                                                  
               
          
 


 

The following are the broadcasts that are sent in various situations:

 

 

1 \ Installation

Android. intent. action. PACKAGE_ADDED


2 overwrite Installation
Android. intent. action. PACKAGE_REMOVED
Android. intent. action. PACKAGE_ADDED
Android. intent. action. PACKAGE_REPLACED


3 \ clear data
Android. intent. action. PACKAGE_RESTARTED
Android. intent. action. PACKAGE_DATA_CLEARED


4 \ force stop
Action: android. intent. action. PACKAGE_RESTARTED


5 \ Uninstall
Android. intent. action. PACKAGE_REMOVED
Android. intent. action. PACKAGE_FULLY_REMOVED

 

How to get the package name in Broadcast

 

ComponentName cn = intent.getComponent() ;Uri uu= intent.getData() ;String name = uu.getSchemeSpecificPart();

Obtain information about apk (not installed:

 

 

 

Public static void Merge (Context context, String apkPath) {PackageManager packageManager = context. Merge (); PackageInfo = packageManager. Merge (apkPath, PackageManager. GET_ACTIVITIES); if (info! = Null) {ApplicationInfo appInfo = info. applicationInfo; String appName = packageManager. getApplicationLabel (appInfo ). toString (); String packageName = appInfo. packageName; // get the installation package name String version = info. versionName; // obtain the version information Drawable icon = packageManager. getApplicationIcon (appInfo); // get the icon information }}


 

 

Related Article

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.