I am making one phone security application in android.
The point where I stuck is that How to set uninstall password for this app.
When application is installed user can set the security password and this password will be used for uninstalling this app.
So please someone suggest me how to put code for uninstall event.?
Is there any event or service called when apps are going to uninstall.?
No, sadly there is no uninstall event that you can catch for your own app.
You can only watch the installation and uninstallation of other apps via the Intent.ACTION_PACKAGE_ADDED (and similar) broadcast(s).
Maybe you can use a deamon runing in background, that can intercept the uninstall of you application.
This deamon would be executed when the phone turns on, or when your application is used.
To run an application when booting your phone: http://www.androidcompetencycenter.com/2009/06/start-service-at-boot/
Refer to Intent.ACTION_PACKAGE_ADDED (and similar) broadcast(s) as alextsc said. (sorry cannot add comments)
android does not give you freedom to perform code when app is uninstalled.
All the settings and application data is deleted which is set by the applicaion
The only thing that will persist is the data that is written to the SD-Card and the changes to phone settings
Related
I'm trying to write an Android service, which starts on boot and works in the background periodically. I have defined the BroadcastReceiver of mine, added the right permissions and all the necessary stuff in manifest.
When I install the APK on my phone and reboot, nothing happens, the program is there in the installed apps section, but not running.
I've seen a user comment stating that "standalone" services are disabled (for security reasons?) since Android 3.1 but I couldn't verify this information anywhere.
Anyone could give me a clear view about this? Without that, I don't know how to proceed: debug or change plans.
Thank you in advance!
Just after the first the first installation of a package, the application is in a "stopped state" preventing it to execute any code for security reasons.
The app loses this particular "stopped state" as soon as the user launch the app explicitly for the first time.
How to prevent an application from being uninstalled. How to stop it using code when user want to delete the application ? How can we do that using programming ?
One possible way may be android os customization. Otherwise I think you can't do this. You can see this Stop uninstallation of application
Without customization, you can get a message(using intent) when user try to uninstall a package.
Device Administrator
Once the application is registered as a Device Administrator, it can't be uninstalled unless its unregistered. This will prevent the app from being uninstalled
You should look at Device Administration .
Once the application is registered as a Device Administrator, it can't be uninstalled unless its unregistered. This will prevent the app from being uninstalled.
You can password protect your application to prevent someone from tampering with the Device Admin features in the app.
Please read this example. It is explaining all the details with sample tutorial.
Is it possible to make my application "un-erasable"? By that I mean a lot of things...
1-Cannot be uninstalled unless the user enters a password for example.
2-If the user restores factory settings then my application and its data won't be deleted.
3-User cannot kill the application; as in force it to end while it's running.
*Note: Sometimes this can be beneficial to the user. In my application, my client almost necessitates such an option to exist.
No
Here's what you're looking for.
No, it's not possible. That would be terribly unfriendly to the user.
One way of making an app uninstallable is getting it baked into the firmware of the handset before its launch. This is usually done by having a tie-up with the wireless carrier, who requires the app to be preloaded by the OEM. But for normal apps delivered through Android Marketplace it is not possible.
Even the apps which comes with system images, >> i mean which comes preinstalled, can be killed by os when it need resources. But user can not erase system apps, So if you want to have your app permanently, start selling you own phone with yours OS in it, with your app isbuilt with os.
Yes it is possible, you need root and chmod your app to 0000
or just put the apk in /system/ partition
Just want to know how to track what applications a user has uninstalled from their device in the past.
There is no log available that you can read way after the apps have been uninstalled (afaik).
All you can do is listen for the ACTION_PACKAGE_REMOVED broadcast while your own app is installed. It contains the package name of an app that the user just uninstalled.
There is no record of that on the phone/device and even if there would be it would not be available to a non-root application.
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.