android not receiving Intent ACTION_PACKAGE_REMOVED in the removed package

前端 未结 2 2146
一生所求
一生所求 2020-12-09 19:30

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.

相关标签:
2条回答
  • 2020-12-09 20:13

    The documentation says:

    The package that is being removed does not receive this Intent.

    Android 2.2 added getExternalFilesDir(), which will point to a place on the external storage that Android will automatically clean up when your application is uninstalled. However, that is only for Android 2.2, and there are indications that it does not work particularly well at the moment. However, it is something to keep in mind for 2011.

    Beyond that, all you can really do is offer a menu choice somewhere for the user to do the cleanup, and hope users use it before uninstalling you.

    0 讨论(0)
  • 2020-12-09 20:13

    You must add the permission in the manifast.

    <uses-permission android:name="android.permission.BROADCAST_PACKAGE_REMOVED" />
    
    0 讨论(0)
提交回复
热议问题