times. However, make sure to only call updateAppWidget() inside the
"if" block, since otherwise you'll be sending updates for odd events
like onDeleted().
j
On Wed, Nov 4, 2009 at 2:02 PM, Evan Ruff <evan.ruff@gmail.com> wrote:
> I don't know if this is EXACTLY kosher, but I've overriden the
> onRecieve method in my AppWidgetProvider to look like:
>
> @Override
> public void onReceive( Context context, Intent intent )
> {
> this.view = new RemoteViews( context.getPackageName(),
> R.layout.widget );
> if (intent.getAction().equals( MY_AWESOME_CUSTOM_INTENT ))
> {
> // DO AWESOME STUFF HERE
> }
> else
> {
> super.onReceive( context, intent );
> }
>
> ComponentName me = new ComponentName( context, VAWidget.class );
> AppWidgetManager.getInstance( context ).updateAppWidget( me,
> view );
> }
>
> Then I just add the custom intents to the widget's intent-filter in
> the manifest as usual.
>
> It has worked every time for me, but I'm wondering if there is a
> scenario where it would not be preferable to do it this way?
>
> E
>
>
> On Nov 4, 1:11 pm, skink <psk...@gmail.com> wrote:
>> Mark Murphy wrote:
>> > skink wrote:
>> > > hi,
>>
>> > > my custom AppWidgetProvider has onUpdate method where i have logic to
>> > > update RemoteViews
>>
>> > > it is not periodically updated by system, but rather, i'd like to
>> > > trigger onUpdate if something happens (in one of my app Activities).
>> > > both custom AppWidgetProvider and Activities i'd like to trigger
>> > > update from run with the same UID
>>
>> > > i tried some AppWidgetManager's methods, but no luck, finally i ended
>> > > with really weird solution: i'm sending broadcast with action
>> > > ACTION_APPWIDGET_UPDATE and extras EXTRA_APPWIDGET_IDS which i got
>> > > from AppWidgetManager
>>
>> > > is it a common way of updating AppWidgetProvider?
>>
>> > You could also just send a broadcast to the provider directly, via the
>> > component-name version of the Intent constructor. Look for a null
>> > action, or some extra you package in, or something to tell it is your
>> > own custom Intent, then do the update work.
>>
>> thank you Mark,
>>
>> this is exactly what i'm doing now - sending broadcast directly to my
>> AppWidgetProvider by manually creating proper Intent and adding some
>> EXTRA_APPWIDGET_IDS extras
>>
>> yet my impression was that this is not the way one should do: i mean i
>> thought there must be some higher level helper method to update
>> AppWidgetProvider
>>
>> pskink
>
> --
> You received this message because you are subscribed to the Google
> Groups "Android Developers" group.
> To post to this group, send email to android-developers@googlegroups.com
> To unsubscribe from this group, send email to
> android-developers+unsubscribe@googlegroups.com
> For more options, visit this group at
> http://groups.google.com/group/android-developers?hl=en
>
--
Jeff Sharkey
jsharkey@android.com
--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscribe@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
No comments:
Post a Comment