Perform a task on uninstall in android
Sadly android at the moment does not give you a possibility to perform code at the moment your app is uninstalled.
All the settings that are set via the SharedPreferences are deleted together with everything in the Application Data an Cache folder.
The only thing that will persist is the data that is written to the SD-Card and any changes to phone settings that are made. I don't know what happens to data that is synchronized to the contacts through your app.
How to Call custom Method at time of uninstallation of application in Android
I'm afraid that you can't control when application is uninstalled. Sorry.
Can code be called when my Android application is uninstalled?
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.
How to show an Activity BEFORE my app is uninstalled (Android)
I noticed that NQ Mobile Security is able to show a message after I click on Uninstall and before the PackageUninstaller is called
They must be exploiting some security flaw in Android. I will research it and see if I can get it fixed. Apps are not supposed to get control at uninstall time.
Thanks for pointing this out!
Is there a different way to intercept your application UNINSTALL event?
I sure hope not.
How do I uninstall and re-run an app on a device using Android Studio?
You can skip the force stop and uninstall step by just hitting run
again. Android Studio should prompt you which device to run on and there you can select your connected device.
It will close the app and re-run your changed version.
Run connectedAndroidTest and skip uninstall
Looking at the sorce of gradle plugin there is no way to prevent uninstalling app at the end of test task. You can check that in SimpleTestCallable
class of android gradle plugin.
From what i see there are two options to acchive what you want.
First one is to reinstall app after your connected check is done. Command to do that would look something like this. ./gradlew connectedCheck installDebug installDebugAndroidTest
This will execute test on device and delete apps from it. But after that it will reinstall app and test app. So app will still be removed and then installed which means a bit of owerhead but at least apps will not be recompiled twice since you are executing in same gradle execution.
Second option is to not use gradle for executing tests but use adb instead.
To do this you first need to install app and test app through gradle../gradlew installDebug installDebugAndroidTest
After that you can execute tests through adb. by caling adb shell am instrument -w com.example.test/android.support.test.runner.AndroidJUnitRunner
.
When this is done you can run your cli tests since both app and test app are still installed.
With second approach you would lose all the benefits of executing test wit gradle. Such as code coverage and executing in multiple proceses, etc.
Related Topics
How to Detect Android App Uninstall
How to Add a Library Project to a Android Project
How to Have Onscrolllistener for a Scrollview
Android Edittext Delete(Backspace) Key Event
How to Create PDFs in an Android App
Using Intents to Pass Data Between Activities
Android: Scale a Drawable or Background Image
Android: How to Auto-Restart an Application After It Has Been "Force Closed"
Singleton Object Becomes Null After App Is Resumed
How to Center Align the Actionbar Title in Android
How to Download Google Play Services in an Android Emulator
Android Difference Between Two Dates
Trying to Attach a File from Sd Card to Email
Android Get Real Path by Uri.Getpath()
What's the Best Way to Iterate an Android Cursor
How to Create a Custom Navigation Drawer in Android
More Than One File Was Found with Os Independent Path 'Meta-Inf/License'