编程删除AppWidgets [英] Removing AppWidgets programmatically

查看:124
本文介绍了编程删除AppWidgets的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在最困难的时候搞清楚如何删除主屏幕AppWidget的编程方式(即没有用户实际上拖一进垃圾桶)。作为一个例子,考虑一个应用程序,可以有多个帐户,与任意数量的部件的每一个帐户的 - 一旦账户被移除,插件应删除,以及

I'm having the hardest time figuring out how to remove home screen AppWidget's programmatically (i.e. without the user actually dragging one into the trash). As an example, consider an app that can have multiple accounts, with any number of widgets for each account - once an account is removed, widget should be deleted as well.

下面从一个不起眼的例子<一个我已经试过href="http://www.netmite.com/android/mydroid/cupcake/frameworks/base/services/java/com/android/server/AppWidgetService.java">http://www.netmite.com/android/mydroid/cupcake/frameworks/base/services/java/com/android/server/AppWidgetService.java,但是这似乎并不甚至引发OnDeleted,更不用说从主屏幕中删除AppWidget。

I've tried following an obscure example from http://www.netmite.com/android/mydroid/cupcake/frameworks/base/services/java/com/android/server/AppWidgetService.java, but that doesn't seem to even trigger OnDeleted, much less remove the AppWidget from the home screen.

Intent intent = new Intent(AppWidgetManager.ACTION_APPWIDGET_DELETED);
intent.setComponent(info.componentName); // references AppWidgetProvider's class
intent.putExtra(AppWidgetManager.EXTRA_APPWIDGET_ID, widgetId);
sendBroadcast(intent);

有没有人对如何能够实现什么建议?一个例子是蜜蜂的膝盖。谢谢你。

Does anyone have any advice on how this can be accomplished? An example would be the bee's knees. Thanks.

推荐答案

您不能添加或从主屏幕上删除应用程序的部件。只有用户可以做到这一点。

You cannot add or remove app widgets from the home screen. Only the user can do that.

任何应用程序部件依赖于被删除的帐户可以显示不同的帐户,或采取一些(帐户被删除)看,将触发用户摆脱了应用程序部件或重新配置。

Any app widgets tied to a deleted account could show a different account, or adopt some "(account deleted)" look that would trigger the user to get rid of the app widget or reconfigure it.

这篇关于编程删除AppWidgets的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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