Hi all. 

I've a quick question pertaining to remote views. 

Is it safe to keep and maintain a copy of the last RemoteViews that was used 
for updating the appwidget? I have a status message that is updated 
regularily (more so than the rest of the widget). Suppose I have something 
like... 

This updates the views (this is called before manager.updateAppWidget( 
ids[i], remoteViews ); )

  void updateAppWidgetFunction( Context context ) {
    RemoteViews remoteViews = new RemoteViews( 
      context.getPackageName(),
      R.layout.main );
      
    // Set all the views stuff
    
    lastRemoteViews = remoteViews;  // lastRemoteViews is a static private 
member of the class
  }


And I have a method that updates the status message like so:

  void updateStatusMessage( String str ) {
    RemoteViews remoteViews = null; 
    if ( lastRemoteViews == null )
      remoteViews = remoteViewsWithIntents( context );
    else
      remoteViews = lastRemoteViews; 
      
    remoteViews.setTextViewText( R.id.textview_status, str );
    refreshWidgetViews( context, remoteViews );
  }



Is this good practise? Or should I make a means of specialising the 
updateAppWidgetFunction to update the status message only? 

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