When my android app is removed, I would like to also remove files the app has created on the SD card, as these can consume many megabytes and are only of use to my app.
It seems that receiving the PACKAGE REMOVED intent would be the place to do this.
However, my broadcast receiver is never called--it seems to have been deleted before the PACKAGE REMOVED intent is sent
The code is:
public class UninstallReceiver extends BroadcastReceiver {
@Override
public void onReceive(Context context, Intent intent) {
String action= intent.getAction();
Log.i("U", "ACTION " + action);
etc.
}
}
and, in the manifest:
<application android:debuggable="true"
android:icon="@drawable/icon"
android:label="@string/app_name">
<receiver android:name ="com.boom.UninstallReceiver">
<intent-filter>
<action android:name="android.intent.action.PACKAGE_REMOVED"/>
<data android:scheme="package" />
</intent-filter>
</receiver>
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…