Thanks a lot Kostya, I was not fully aware of the onEnable(),
onDisable() funcionality. It works pretty well now :)


On Jun 24, 10:08 pm, Kostya Vasilyev <kmans...@gmail.com> wrote:
> Albert,
>
> 25.06.2010 0:29, Albert ?????:
>
>
>
> >> >  The AppWidgetProvider is notified on every add and remove operation,
> >> >  along with first-add and last-remove operations.
>
> > I have tried that but there are scenarios in which is does not work,
> > the user for example could have 2 instances of the widget and then
> > delete one...
>
> It works, first you get APPWIDGET_DELETED for the deleted widget id,
> then possibly APPWIDGET_DELETED for the other one (or APPWIDGET_UPDATE
> with some new widget id).
>
>
>
> >> >  Or, you can ask your AppWidgetManager getAppWidgetIds().
>
> > I can definetly use this. I have played a bit with the onUpdate() and
> > onDeleted() methods and I can see a new value (id) generated for each
> > instance of the widget, so now I can use it to know whether I have any
> > on the homescreen, thus I will not have a service running with no
> > widget:)
>
> There are actions just for this:
>
> http://developer.android.com/reference/android/appwidget/AppWidgetPro...
>
>     public static final String ACTION_APPWIDGET_ENABLED
>
>     Sent when an instance of an AppWidget is added to a host for the
>     first time. This broadcast is sent at boot time if there is a
>     AppWidgetHost installed with an instance for this provider.
>     See Also AppWidgetProvider.onEnabled(Context context)
>
>     public static final String ACTION_APPWIDGET_DISABLED
>
>     Sent when an instance of an AppWidget is removed from the last host.
>     See Also AppWidgetProvider.onEnabled(Context context)
>
> However, if your service is for just updating the widget, you can do
> startService from onUpdate(), have the service update all your widgets
> (using AppWidgetManager updateAppWidget (ComponentName provider,
> RemoteViews views)), and exit.
>
> --
> Kostya Vasilev -- WiFi Manager + pretty widget --http://kmansoft.wordpress.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+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to