如何删除插件时,应用程序卸载在Android的? [英] How to remove widget when the app is uninstalled in Android?

查看:159
本文介绍了如何删除插件时,应用程序卸载在Android的?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

可能重复:
  <一href="http://stackoverflow.com/questions/1860901/removing-widget-from-home-screen-when-uninstalled">Removing窗口小部件从主屏幕时,卸载

在Android中,我创建了一个小工具我的应用程序。当我卸载应用程序,小部件显示问题加载插件的错误在主屏幕。我需要这样一个场景:小部件应通过code中的显影剂除去(而不是由拖放到垃圾桶),当我卸载应用程序。可能吗?如果是这样,有什么变化,我们需要做什么?有没有什么事情可以让它消除了应用程序的所有引用一旦卸载清单中设置?

In Android, I have created a widget for my application. When I uninstall the app, the widget shows "problem loading widget" error in home screen. I need a scenario where widget should be removed by the developer through code (and not by the drag and drop to the trash) when I uninstall the app. Is it possible? If so, what changes we need to do? Is there anything that can be set in the manifest so that it removes all references of the app once it is uninstalled?

推荐答案

你好! 当您删除的应用程序部件主机管理者应该播出下列意图之一... ACTION_APPWIDGET_UPDATE ACTION_APPWIDGET_DELETED ACTION_APPWIDGET_ENABLED ACTION_APPWIDGET_DISABLED

Hiya! When you delete the app widget host manager should broadcast one of the following intents... ACTION_APPWIDGET_UPDATE ACTION_APPWIDGET_DELETED ACTION_APPWIDGET_ENABLED ACTION_APPWIDGET_DISABLED

要充分利用这一点,在你的appwidget提供类(或广播接收机的自定义扩展)接收广播(或appwidgetprovider类使用onDeleted()),并从应用程序部件主机管理的ID删除插件窗口小部件的......

To make use of this, in your appwidget provider class (or your custom extension of broadcast receiver) receive the broadcast (or use onDeleted() in the appwidgetprovider class) and delete from the application widget host manager the widget with the id of your widget....

希望这有助于...

这篇关于如何删除插件时,应用程序卸载在Android的?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆