I want to implement something like AppLock application is doing.
If in its settings it is set to lock applications uninstall/install, then while uninstalling any app (precisely on clicking the Uninstall button) a lock screen comes which asks for a password/pattern.
Only after entering the password user is allowed to uninstall the app.
What's that intent(or anything, I assume it to be an intent but not sure) that one get when Uninstall button is clicked?
Also I dont want to make it device admin, as the app I mentioned does require to be device admin.
If they can do it, then there is some way.
Please help.
I have found a way.
When you go to Settings -> Manage Apps -> Click on any app.
you get a broadcast with name of the package in extras.
When you click on the Uninstall button on that screen,
an activity is opened always name com.android.uninstaller.UnistallerActivity
.
So the solution to this problem is a combined way of 1 and 2 steps mentioned above.
When ever you get the intent mentioned in first step and the extras contain the package name of your app start an activity watcher using PackageManager
by which you get the top most visible activity and its package.
So now if uninstaller activity is launched then you can be sure that user wants to uninstall your app.
There after you can do necessary action to stop him to do that.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With