当我的 android 应用被删除时,我还想删除该应用在 SD 卡上创建的文件,因为这些文件会消耗很多兆字节并且只对我的应用有用.
似乎接收 PACKAGE REMOVED 意图将是执行此操作的地方.但是,我的广播接收器从未被调用——它似乎在发送 PACKAGE REMOVED 意图之前已被删除
代码是:
<上一页>公共类 UninstallReceiver 扩展 BroadcastReceiver {@覆盖公共无效 onReceive(上下文上下文,意图意图){字符串动作=意图.getAction();Log.i("U", "动作" + 动作);等等.}}并且,在清单中:
<上一页><应用程序 android:debuggable="true"android:icon="@drawable/icon"android:label="@string/app_name"><receiver android:name="com.boom.UninstallReceiver"><意图过滤器></意图过滤器></接收者>文档 说:
<块引用>被移除的包没有收到这个 Intent.
Android 2.2 添加了 getExternalFilesDir(),它将指向外部存储上的一个位置,Android 将在您的应用程序卸载时自动清理该位置.但是,这仅适用于 Android 2.2,并且有迹象表明它目前运行得不是特别好.但是,在 2011 年要牢记这一点.
除此之外,您真正能做的就是在某处为用户提供一个菜单选项来进行清理,并希望用户在卸载您之前使用它.
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>
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.
这篇关于android 在已删除的包中没有收到 Intent ACTION_PACKAGE_REMOVED的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!
Android 上的数字软键盘Numeric Soft Keyboard on Android(Android 上的数字软键盘)
带有软键盘和“返回"的 EditText按钮EditText with soft keyboard and quot;Backquot; button(带有软键盘和“返回的 EditText按钮)
在 Android 上的应用程序中内置自定义“键盘&quoCustom #39;Keyboard#39; built in an application on Android(在 Android 上的应用程序中内置自定义“键盘)
如何在 Android 的移动网站中强制使用带有数字的How to force keyboard with numbers in mobile website in Android(如何在 Android 的移动网站中强制使用带有数字的键盘)
启动 Activity 时自动弹出键盘Automatic popping up keyboard on start Activity(启动 Activity 时自动弹出键盘)
如何制作 Android EditView“完成"按钮并在单击时How do I make an Android EditView #39;Done#39; button and hide the keyboard when clicked?(如何制作 Android EditView“完成按钮并在单击时隐藏