Hi Kostva, Long time no access. The widgetprovider name is right. Refer to "which widget coming", I meant that if the same widget provider has different widget instances on Home Screen, then we can not know what is the ID of the current widget that the user interacts with. Through getAppWidgetIds() method, I wanted to get how many instances of widget that the same widget provider owns. But it failed.
I still have no idea of this. Thanks On Sep 21, 6:08 pm, Kostya Vasilyev <[email protected]> wrote: > Make sure that ComponentName you use to get AppWidgetManager matches the > widget provider in the manifest. If it doesn't, you'll get an empty list > (ids.length = 0, the loop won't execute). > > Not sure what you mean by "which widget coming". > > -- > Kostya Vasilyev --http://kmansoft.wordpress.com > > 21.09.2010 11:56 пользователь "Jerome Deng" <[email protected]> написал: > > Hi guys, > I have searched many topics about AppWidgetManager.getAppWidgetIds(). > But I don't get any compellent answers. In my code, I first get all > widget ids by > AppWidgetManager.getAppWidgetIds(provider), and then do a for loop as > below: > for (int id : ids) {...} > However, I see the for loop never executed. And if I call ids.length, > the sentence never executed yet. > > Some people said getAppWidgetIds() can not return the right id set, > that is because the some widgets were deleted but their ids are still > there. > > My target is to know how many widgets are created by the specified > widget provider, so I think getAppWidgetIds() can meet this. But it > fails now. > > I think getAppWidgetIds() has something wrong, and the widget > framework should fix this. Also, in widget provider, if it can > distinguish which widget instance is coming, that means the current > widget id can be passed in, then all things will be better. Why not do > this in widget framework? > > -- > 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]<android-developers%[email protected]> > For more options, visit this group > athttp://groups.google.com/group/android-developers?hl=en -- 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

