i am aware of android BROADCAST_PACKAGE_REMOVED for notify when any application is uninstalling from device.
Now it is possible that when i uninstall one application and that application do some work before and uninstall.
e.g: my application work with android contact if application uninstall at that time i want to change in contact data.
can i get any event for uninstalling app?
Thanks.
No.
(at least until the current version of Android)
In case it's any help, widgets do get notified when their last instance is removed. However, the app than contains the widget remains installed.
Related
I'm trying to understand what exactly happens after my app gets updated on the users devices.
As of course the 'MainActivity' isn't launched, I am wondering about the services.
I have one START_STICKY service and one which is not, does the START_STICKY auto-start after the update, what about the other ?
Is there any way of testing this behavior without waiting for a real Play Store update ?
I looked for a documentation regarding this issue but couldn't find anything related.
I just did a quick test. Not sure how close this is to an actual update on the Play Store or if it is in any way comparable, but here goes:
I have created a simple app that starts two services on the click of a button, one START_STICKY one START_NOT_STICKY.
Both services create a notification in onStartCommand() and show a version number.
I create one release APK, change the version number in Manifest and notification, and create another release APK. I've copied the two APKs onto the phone and disconnected the phone.
I've manually installed the first APK on the phone, started the app, clicked the button, two notifications appear. Installed the second APK, without starting the app. The two notifications disappeared and did not re-appear either. Opened the app, clicked the button, both notifications appeared with the new version number.
From this it appears that neither service will be restarted automatically after an app update.
You could also publish your app on Google Play as an Alpha version and test an update of your app without annoying general users.
I wonder there is any way when user completely uninstall my app ,few days later a push notification asks user install new apps.
Is it possible?
You cannot perform operations after your app has been removed. Unfortunately there is currently no way for an Android package to execute code when it is removed. However, you can register a BroadcastReceiver for ACTION_PACKAGE_REMOVED in a different package that will be called when packages are removed from the phone.
Also see this question.
No there is no way except the client has installed two of your apps. But however don't do that!
I have an android app, I want to run some process or show some message to user if he is uninstalling app, how to do that in android...
You could have a second app set up to receive a PACKAGE_REMOVED broadcast when the original app is removed. I don't think you can affect the first app being removed, but you at least you can react to it (to clean up files, etc.). That would only work, of course, if the second app was not removed first.
Not possible. If your user wants to uninstall your app, why do you think it would be OK to have anything pop up before they can do that?
Is there any way to determine programmatically the time at which an Android application was installed? I don't see anything in PackageInfo, etc.
--EDIT--
To clarify, App A is installed at Time X. At some later time, Time Y, App B is installed. Is there any way App B can know when App A was installed? The link How to get app install time from android indicates that reading the modify time on the source dir of the App is sufficient. Is this really correct? Why?
When you install/update a non-protected app, it's apk file gets written to /data/app/package.name.apk, confusingly referenced as sourceDir (from my answer) resetting the timestamp to the current one. That's it.
are you trying to find the time when YOUR app was installed, or other apps? If you are only interested in your own app, you can add functionality to your app that checks if this is the first time the app has been run. if it is, get the system time and save it in a file/database. then whenever you want it, you can open the file/query the database for it.
Was this helpful?
Register a BroadcastReceiver for the corresponding Intent.
Is there a way to get a system notification when an app has been uninstalled?
I would like to maintain a table of all clients' info currently using my app. However, that seems impossible if there is no way to detect this event.
The first solution I can think of is to have an always running service in the background listening for android.intent.action.PACKAGE_REMOVED. But then would that service be killed once the uninstallation process has ended, or would it be stopped just before the process has kicked off? Also even if this is a solution it's has the potential to put off a lot of people when they realise that part of the app is running in the background.
Any suggestions? Thanks!
You could simply do it the other way round and maintain a table of users actively using your app. Just call a webservice at a point in the program that show it is active. If an app isn't used for a certain time mark it as inactive.
The documentation for the PACKAGE_REMOVED action says the following:
The package that is being uninstalled does not receive this Intent.
So you can monitor for other applications being uninstalled but not your own.
So you'll probably need track who is still using your application, not who has stopped using it. If you don't want the overhead of having your own server to do this you could use a free service like Flurry.
From Android document, the app uninstalled by user can't not get
Intent.ACTION_PACKAGE_REMOVE
But we can use other method to implement this feature. We all know that there is a directory named with your package name under the /data/data directory after your app installed by user. If your app is uninstalled by user, the root directory of your app(/data/data/com.example.yourappname) will be removed by system. The remove action happen immediately when user click "uninstall", and the directory will be removed by framework package manager system.
So, we can monitor the existence of your app data directory(which usually /data/data/com.example.yourappname) to detect if your app uninstalled by user.
In order to monitor this directory, we have to fork a detached process from JNI.
In this new fork process, we can use Linux system api inotify(7) or access(3) to determine the existence of app's data directory.
Here is a workable implementation. But it got the permission problem when try to send an intent to start system browser on high version Android device. I have no idea how to bypass this. However the example above is enough for your question.
Hope it will be helpful!
Android doesn't provide an inbuilt function for tracking the app uninstall.
Notification can be used as an alternate way to track the app uninstall. For this send notification on the app and track the status of the notification. Count the number of undelivered notification for a particular time period. If status of undelivered notification doesn't change in that particular time period, then consider that the app has been uninstalled from the device.
For example, i have used a cron script which run every 3 days and check the status of last 10 notifications delivered to the device (2 notifications are sent in a day). If all of these 10 notifications have status "undelivered", then the app is considered to be uninstalled from the device.