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 }}