Redrawing Widget When Changing Orientation

by Matt M » Tue, 27 Apr 2010 05:03:42 GMT


Sponsored Links
 Hello,

I have a widget set up and it displays properly in both portrait and
landscape when added to each. But when I change orientation it has the
problem "Problem Loading Widget". I delete this, re-add the widget,
and it displays correctly. Thus, my widget can support both portrait
and landscape but it doesn't survive an orientation switch.

What am I missing? Do I need to redraw the widget when orientation is
changed? Doesn't it do this automatically? Do I need to call
onUpdate() somehow?

Thank you!

Matt.

--



Redrawing Widget When Changing Orientation

by Matt M » Wed, 28 Apr 2010 08:20:06 GMT


 I've discovered the method call that causes the problem but I still
don't understand why..

In an activity, after saving and exiting I make a static method call
MyAppWidget.forceUpdate(this, "text");

Below is the method which updates the text of the widget
    public static void forceUpdate(Context context, String note)
    {
        if (context != null)
        {
                ComponentName thisWidget = new
ComponentName(context,WhiteboardWidget.class);
                AppWidgetManager manager =
AppWidgetManager.getInstance(context);
                RemoteViews views = new
RemoteViews("whiteboard",R.layout.widget_layout);
                views.setTextViewText(R.id.boardNote, note);
                manager.updateAppWidget(thisWidget, views);
        }
    }

Any ideas now??

--


Sponsored Links


Other Threads

1. ViewFlipper Help Please

Hi everyone,

I am currently using a ViewFlipper to move through some views. It
works fine when I want to move sequentially through IE 1,2,3,4 or
4,3,2,1 My question is if I want to go from say 1 to 4 when a button
is clicked how should I do this? Currently I use the following bit of
code but im not sure this is the correct way to go about it.

int x = 0;
                                               do{
                                                   
flipper.setInAnimation(inFromRightAnimation());
                                                        
flipper.setOutAnimation(outToLeftAnimation());
                                                        flipper.showNext();
                                                        x = x +1;
                                               }while(x <= 5);
                                                }

Thanks for your time and help,

Tommy

-- 

2. Sensors with thread or not?

I have an activity, that uses sensor strongly. Until now I have
managed the sensor with a background thread, because I thought it was
better to understand and to develop my app, but now I'm not sure about
it. The performance is very low.

Do you think i should use sensor in the activity directly, without
using thread? Generally which is the best way?

-- 

3. R: Use of Service class

4. What is meaning of context?

5. Temporarily change soft keyboard language

6. Gallery Audio bounce effect on seekTo

7. Sim Contacts