Sorry, I'll answer my own question:
I should have used PendingIntent.getBroadcast rather than
PendingIntent.getActivity, as in:
PendingIntent pendingIntent =
PendingIntent.getBroadcast(
context,
0, // no requestCode
new Intent
(AppWidgetManager.ACTION_APPWIDGET_UPDATE),
0 // no flags
);
On Jan 5, 11:42 pm, kostmo <[email protected]> wrote:
> Hello,
> I am overriding onReceive() in my subclassed AppWidgetProvider. My
> home screen widget works fine with a periodic update. I would like to
> have a click on the widget cause the widget to update.
>
> When building the RemoteView, I set a PendingIntent as follows:
> PendingIntent pendingIntent = PendingIntent.getActivity
> (
> context,
> 0, // no requestCode
> new Intent
> (AppWidgetManager.ACTION_APPWIDGET_UPDATE),
> 0 // no flags
> );
> updateViews.setOnClickPendingIntent(R.id.widget,
> pendingIntent);
>
> Earlier I had established that the PendingIntent was functional when
> using ACTION_VIEW and a web url for the data URI; clicking the widget
> launched the browser. My manifest has this broadcast receiver:
>
> <receiver android:name=".widget.CharacterWidget"
> android:label="@string/widget_name">
> <intent-filter>
> <action
> android:name="android.appwidget.action.APPWIDGET_UPDATE" />
> </intent-filter>
> <meta-data android:name="android.appwidget.provider"
> android:resource="@xml/widget_character" />
> </receiver>
>
> However, the onReceive() method in my AppWidgetProvider never gets
> called, although I see the following message in my LogCat:
> Starting activity: Intent
> { act=android.appwidget.action.APPWIDGET_UPDATE }
>
> What do I need to change to get this to work?
--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en