You can only attach a widget to a view if you use the pick app widget
intent.
You can attach as many as you want, I didn't see a limit yet.
I can point you to a working sample I used:
http://www.anddev.org/advanced-tutorials-f21/appwidgethost-tutorial-t10329.html
Only thing you need to fix is this part:


   1. protected void doWidgetPick() {
   2.
   3.         int appWidgetId = WidgetScreen.this.mAppWidgetHost.
   allocateAppWidgetId();
   4.
   5.
   6.
   7.     Intent pickIntent = new Intent(AppWidgetManager.
   ACTION_APPWIDGET_PICK);
   8.
   9.     pickIntent.putExtra(AppWidgetManager.EXTRA_APPWIDGET_ID,
   appWidgetId);
   10.

Remove WidgetScreen.
Should compile after that.

If you ever find a way to save the widgets and restore them, I would love to
hear your solution.

Richard Lalancette
Ottawa, Ontario, Canada


On Fri, Aug 19, 2011 at 5:05 AM, 李白|字一日 <[email protected]> wrote:

> do you mean it is possible to have an application with multiply widgets?
>
> i want to have my application bind a widget, but i still haven't find a way
> by now.
>
>
> 2011/8/16 Richard Lalancette <[email protected]>
>
>> Hi all,
>>
>> I had hope to use the AppWidget in our next solution concept, but I have
>> faced a serious problem doing so yesterday.
>>
>> Adding widgets to our app worked like a charm until I started looking into
>> saving the current widget to be able to restore them on the next launch of
>> our app.
>>
>> A large part of the app was to rely on restoring widgets upon reload, but
>> unfortunately I couldn't figure out how to do so.
>>
>> If any of you have information on saving and restoring AppWidget states, I
>> would love to hear.
>>
>> I have tried using bindAppWidgetId(appWidgetId, widget); but this is not
>> allowed by the system and returns a system exception.
>>
>> Other solutions found on the web rely on copying my app to the /system/...
>> folder, but that would mean I need to root the device and remove the
>> read-only flag from that folder which I do not wish to do.
>>
>> It would be totally not practical to re-pick all widgets each time the app
>> is launched, this is just make any sense.
>>
>> Thanks in advance
>>
>> Richard Lalancette
>> Mobile Application Developer
>> Alcatel-Lucent Canada
>> Ottawa, Ontario, Canada
>>
>> --
>> 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
>
>
>  --
> 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
>

-- 
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

Reply via email to