When you uninstall an Android app, you often pop up a webpage and do some survey statistics on your user data. Android is able to get to other apps that are uninstalled from this event, but can't get itself unloaded by this event. From the pure Java layer is impossible to achieve, This article describes a method to implement it.
Principle
In simple terms, create a background process to monitor the folder's delete events. For example, the app's package name is Com.myname.myapp, the background Process monitoring folder is/data/data/com.myname.myapp. How to monitor the folder is deleted this event is mainly used by the INotify series functions, which are described in another way of implementing process communication in JNI.
Watch out.
-
Background process only need one on the line, do not need multiple, before I noticed that a penguin product to do this function, the background started a number of processes. How is it implemented? You can refer to the Android JNI layer to ensure that only one implementation of the process provides a way of thinking.
-
Several key test cases: a. Clean the app's data B. Upgrade app C. Force the app to close and restart the app.
Code
GitHub Address Uninstallwatcher
Code implementation and demo have, the interface has been packaged well, to determine whether the background process is unique, a bit too simple, Welcome to complete the code .
The code is also very simple to use.
public class DemoApp extends application{@Overridepublic void OnCreate () {log.i ("Uninstalldemoapp", "onCreate"); Watchdog.init2 ("Com.bananachip.uninstall", "libwatchdog.so", watchdog.getuserserial (This), "http://www.baidu.com" ); Super.oncreate ();}}
Programmers can understand and do not explain.
In this implementation, it is simpler to judge whether the process exists, just the query process name libwatchdog.so. You should change your name when you use it.
How do I compile?
The JNI section is not compiled by Eclipse.
CD JNI
Ndk-build
Rename.bat
Run demo with Eclipse
Other
1. This article refers to other blogs, but there are a lot of problems with blogging.
2. Not all Android models will be able to pop up web pages after deleting the app, such as Xiaomi, Red rice, which can be added to the background process for additional management.
------------Welcome anticipate
------------by Jacksonke
An implementation of uninstalling the Android app pop-up browser