Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I do something before uninstalling my android app?

I found how to detect uninstall event and test following code.

In Receiver.java:

    @Override
public void onReceive(Context context, Intent intent) {
    String action = intent.getAction();
    Log.d(TAG, "received broadcast : " + action);
}

In manifest.xml:

<receiver android:name="....base.BaseAppReceiver">
            <intent-filter>
                <action android:name="android.intent.action.PACKAGE_REMOVED"/>
                <data android:scheme="package"/> 
            </intent-filter>
        </receiver>

But it detected when only other app was uninstalled. I want to do something before uninstalling "my" app not "other" app. Please, Let me know how can my app detect uninstalling event for processing something before uninstalling my app if it can.

like image 869
nao0811ta Avatar asked Oct 02 '22 18:10

nao0811ta


1 Answers

This is not possible, sorry. If you put your files in the proper directories, they will be deleted automatically, but no other work can be done when your app is uninstalled.

like image 107
CommonsWare Avatar answered Oct 05 '22 10:10

CommonsWare