[Android] Android listens to apk installation and replacement to uninstall Broadcast
First, you need to obtain the application installation status, in the form of Broadcast
The following are application-related Broadcast actions:
ACTION_PACKAGE_ADDED a new application package has been installed on the device, and the data includes the package name (this broadcast cannot be received by the latest package Program)
ACTION_PACKAGE_REPLACED install a new version of the application to the device and replace the existing version.
ACTION_PACKAGE_CHANGED an existing application package, including the package name
ACTION_PACKAGE_REMOVED an existing application package has been removed from the device, including the package name (this broadcast cannot be received by the package program being installed)
The ACTION_PACKAGE_RESTARTED user restarts a package, and all processes in the package will be killed. All running time States associated with the package should be removed, including the package name (the package re-start program cannot receive this broadcast)
The ACTION_PACKAGE_DATA_CLEARED user knows the data of a package, including the package name (the package clearing program cannot receive this broadcast)
Code Implementation
Define broadcast in AndroidManifest. xml
<receiver android:name==> <intent-filter> <action android:name= /> <action android:name= /> <action android:name= /> <data android:scheme= /> </intent-filter> </receiver>
Here we use
ACTION_PACKAGE_ADDED a new application package has been installed on the device, and the data includes the package name (this broadcast cannot be received by the latest package Program)
ACTION_PACKAGE_REPLACED install a new version of the application to the device and replace the existing version.
ACTION_PACKAGE_REMOVED an existing application package has been removed from the device, including the package name (this broadcast cannot be received by the package program being installed)
Let's look at AppInstallReceiver.
AppInstallReceiver = "installed successfully" + = "uninstalled successfully" + = "replaced successfully" +
The code implementation is relatively simple. Based on the received Action, determine whether the application is installed, uninstalled, or replaced with another version.
//////////////////////////////////////// //////
Reprinted original statement, please note
This article is from Ray-Ray's blog
Document address http://www.cnblogs.com/rayray/p/3178403.html
Thank you for your recommendation and favorites.
Your support! Our motivation!