title: dataSnapshot retrieves last message but having difficulty displaying it on widget......?
body: <p>Finishing of a chat app and have researched lots of questions here (found 1 which put me on track <a href="https://stackoverflow.com/questions/4433464/settextviewtext-not-updating-widget">setTextViewText not updating widget</a>)
  As you'll see from my code I have followed that question however, Widget is not updating with message. I have debugged and can confirm that last message has been retrieved.</p>
  
  <p>my code:</p>
  
  <pre><code>public class ProTalkWidget extends AppWidgetProvider {
  
      private static final String ACTION_BROADCASTWIIDGET = "ACTION_BROADCASTWIIDGET";
      public static final String PROTALK_APPWIDGET_UPDATE = "PROTALK_APPWIDGET_UPDATE";
  
      private final int REQUEST_CODE = 0;
      public static final String USER_ID = "userId";
      DatabaseReference rootRef = FirebaseDatabase.getInstance().getReference();
      FirebaseAuth mAuth = FirebaseAuth.getInstance();
      String msgReceiverId;
  
      private void updateAppWidget(Context context, AppWidgetManager appWidgetManager,
                                   final int appWidgetId) {
  
          //Construct the RemoteViews object
          final RemoteViews views;
          views = new RemoteViews(context.getPackageName(), R.layout.pro_talk_widget);
  
  
  
  
          Intent mainIntent = new Intent(context, ChatRoomActivity.class);
          PendingIntent mainPendingIntent = PendingIntent.getActivity(context, REQUEST_CODE, mainIntent, PendingIntent.FLAG_UPDATE_CURRENT);
  
  
          views.setOnClickPendingIntent(R.id.widget_layout, mainPendingIntent);
          Intent intent = new Intent(context, ProTalkWidget.class);
          intent.setAction(ACTION_BROADCASTWIIDGET);
  
          context.sendBroadcast(intent);
  
          appWidgetManager = AppWidgetManager.getInstance(context);
          appWidgetManager.updateAppWidget(appWidgetId, views);
      }
  
      @Override
      public void onReceive(Context context, Intent intent) {
          super.onReceive(context, intent);
  
  
  
          if(PROTALK_APPWIDGET_UPDATE.equals(intent.getAction())){
  
              Log.i("onReceive", "getting onReceived!");
  
  
              handleMsg(intent, context);
  
  
          }
          }
  
  
      private void handleMsg(Intent intent, final Context ctx){
  
          msgReceiverId = intent.getStringExtra("receiverId");
  
  
          if(msgReceiverId!=null) {
              final RemoteViews views;
              views = new RemoteViews(ctx.getPackageName(), R.layout.pro_talk_widget);
  
              String my_Id = mAuth.getCurrentUser().getUid();
  
  
              DatabaseReference msgRef = rootRef.child("Messages").child(my_Id).child(msgReceiverId);
              Query msgQuery = msgRef.limitToLast(1);
  
              msgQuery.addValueEventListener(new ValueEventListener() {
                  @Override
                  public void onDataChange(DataSnapshot dataSnapshot) {
  
                      if(views != null) {
  
                          Messages messages = dataSnapshot.getValue(Messages.class);
                          String msg = messages.getMessage();
  
                          Log.i("Views", "views");
  
                          views.setTextViewText(R.id.appwidget_message, msg);
  
                      }else{
                          Log.i("Views", "not working");
                      }
                      }
  
  
                  @Override
                  public void onCancelled(DatabaseError databaseError) {
  
                  }
              });
  
          }
  
      }
  
  
      @Override
      public void onUpdate(Context context, AppWidgetManager appWidgetManager, int[] appWidgetIds) {
          // There may be multiple widgets active, so update all of them
          for (int appWidgetId : appWidgetIds) {
              updateAppWidget(context, appWidgetManager, appWidgetId);
          }
          super.onUpdate(context, appWidgetManager, appWidgetIds);
      }
  
      @Override
      public void onEnabled(Context context) {
          // Enter relevant functionality for when the first widget is created
      }
  
      @Override
      public void onDisabled(Context context) {
          // Enter relevant functionality for when the last widget is disabled
      }
  }
  </code></pre>
  
  <p>Any help or resources or bits of advice greatly appreciated and welcome.</p>
  
  <p>Thanks</p>
  
  <p><a href="https://i.stack.imgur.com/dDi7b.png" rel="nofollow noreferrer">Appwidget with no message being displayed</a></p>
  
  <p>plus in the logs I'm not getting any error jus the logs of views which I guess represent all the messages loaded(unsure I'm a newbie!).</p>
  
  <p>Thanks again!</p>
  
  <p>Messages</p>
  
  <pre><code>public class Messages {
  
      private String message;
      private String from;
      private String type;
      private long time;
      private boolean seen;
  
      public Messages(){}
  
      public Messages(String message,String from, String type, long time, boolean seen) {
          this.message = message;
          this.from = from;
          this.type = type;
          this.time = time;
          this.seen = seen;
      }
  
  
  
      public String getMessage() {
          return message;
  
      }
  
      public void setMessage(String message) {
          this.message = message;
      }
  
      public String getFrom() {
          return from;
      }
  
      public void setFrom(String from) {
          this.from = from;
      }
  
      public String getType() {
          return type;
      }
  
      public void setType(String type) {
          this.type = type;
      }
  
      public long getTime() {
          return time;
      }
  
      public void setTime(long time) {
          this.time = time;
      }
  
      public boolean isSeen() {
          return seen;
      }
  
      public void setSeen(boolean seen) {
          this.seen = seen;
      }
  }
  </code></pre>
  
  <p>logs <a href="https://i.stack.imgur.com/ArPTw.png" rel="nofollow noreferrer">logcat</a></p>
  
  <p>Debugger datasnapshot value of message <a href="https://i.stack.imgur.com/Eq8SG.png" rel="nofollow noreferrer">datasnapshot</a></p>
  
  <p>Firebase db structure <a href="https://i.stack.imgur.com/zDjkL.png" rel="nofollow noreferrer">DB Structure</a></p>