本文介绍了如何接收意向。 ACTION_PACKAGE_ADDED意图。在appwidget ACTION_PACKAGE_REMOVED?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何接收 Intent.ACTION_PACKAGE_ADDED
和 Intent.ACTION_PACKAGE_REMOVED
在appwidget?
How to receive Intent.ACTION_PACKAGE_ADDED
and Intent.ACTION_PACKAGE_REMOVED
in appwidget?
我试着在清单中添加的意图过滤器:
I've tried to add intent-filter in Manifest:
<application
android:icon="@drawable/ic_launcher"
android:label="@string/app_name" >
<!-- The widget provider -->
<receiver android:name=".NetsWidgetProvider">
<intent-filter>
<action android:name="android.intent.action.PACKAGE_REMOVED"/>
<action android:name="android.intent.action.PACKAGE_ADDED"/>
<action android:name="com.oozic.widget.incstage.nets.ACTION_NOT_INSTALL"/>
<action android:name="android.appwidget.action.APPWIDGET_UPDATE" />
</intent-filter>
<!-- This specifies the widget provider info -->
<meta-data android:name="android.appwidget.provider"
android:resource="@xml/widgetinfo" />
</receiver>
</application>
和我也尝试在code寄存器:
and I also tried register in Code:
@Override
public void onEnabled(Context context) {
registerReceiver(context);
Utils.log(TAG, "Register PACKAGE_ADDED PACKAGE_REMOVED");
}
private void registerReceiver(Context context) {
IntentFilter filter = new IntentFilter();
filter.addAction(Intent.ACTION_PACKAGE_ADDED);
filter.addAction(Intent.ACTION_PACKAGE_REMOVED);
context.getApplicationContext().registerReceiver(this, filter);
}
但都没有奏效。
谢谢!
But both didn't work.Thanks!
推荐答案
我发送一个广播给我的小部件,在我的自定义启动时,它得到PACKAGE_REMOVED /添加的消息。这大约是我找到解决这一问题的唯一作品。
I send a broadcast to my widget, in my custom launcher when it get the PACKAGE_REMOVED/ADDED message. This is the only work around I found to fix this.
这篇关于如何接收意向。 ACTION_PACKAGE_ADDED意图。在appwidget ACTION_PACKAGE_REMOVED?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!