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. listeners in popupwindow

Hi all,

    I have one activity , Which has the menu "update" .Whenever i
click on update button. I am creating pop up window.In that ,
following is the code snippet ,

PopupWindow loginPopUp = new PopupWindow(this);
loginPopUp.setContentView(this.getLayoutInflater().inflate
(R.layout.login_page, null, false));

Here i am setting login_page.xml to content view.In this i have two
buttons.I need to perform something in click of those buttons.
I have tried , I created one activity in that I am loading the same
XML in contentView , There I have registered  with onClickListeners
but whenever i click that button public void onClick(View v) {} this
function is not getting triggered.

any solution ?


-Ashok.

--~--~---------~--~----~------------~-------~--~----~

2. I just have to say thanks to google. The iPhone review process was killing me, but this is great

Hello fellow android devs!

I've been making free mobile games for years(Midp), and shifted focus
to iPhone last year because my primary advertising partner was doing
the same. It's been hell. The only games I've attempted to release on
the iPhone are fairly simple, yet apple spends months to review only
to reject for reasons that don't make sense. Sometimes a game or
update would go through without problem, but since February of 2009
app approvals have been a nightmarish process. Of course there was
also the annoying hardware investments that were needed Mac, iPhone,
and unreliable Xcode IDE . Eclipse is much better.

While I was waiting for one of my game updates to be 'reviewed', I
managed to develop and release an entire android port of my iPhone
game. I even completely rewrote the server and client side code for
this thing. I was stunned when my game was available on the
marketplace within seconds of uploading the .apk file.

So, I want to say a great big thank-you to Google for making the
release process straight forward and non obtrusive.

Later,
Adam.

--~--~---------~--~----~------------~-------~--~----~

3. Android NDK problem withe samples

4. Retrieving Google/GTalk Account bound to Android?

5. Control standardization - Moving forward

6. Wat to buy???

7. Porting Android on a Non-Mobile SoC