title: How to restart and update a widget from a system reboot android
body: <p>i have an appwidget that runs successfully. now when the phone is being rebooted,
  the widget loses all its data and just sits on the home screen. since i can't update the widget from a broadcast receiver when the phone reboots, i created a notification
  that leads to the configuration activity of the widget. Nothing works after the user sets the configuration again and leaves the configuration activity; the idle widget just remains there?(the user has to delete the widget and create a widget again).. Am assuming i am not receiving the widget id correctly or am i doing it wrongly in broadcast receiver and suppose to move all the code to onEnable in the widget method?.. How do i refresh the widget correctly. Please bear in mind that all widget updates are done from a service. </p>
  
  <p>by the way i have this code in broadcast receiver for boot_completed action:</p>
  
  <pre><code>public void onReceive(final Context context, Intent intent) {
  
          String  info = context.getResources().getString(R.string.restart_setting);
  
       int[] allids = AppWidgetManager.getInstance(context).getAppWidgetIds(new ComponentName(context, MyWidgetProvider.class));
          for(int appWidgetId:allids){
  
          NotificationManager mnotifyManager = (NotificationManager)context.getSystemService(Context.NOTIFICATION_SERVICE);
          Notification notify = new Notification(R.drawable.icon, "Weather Update", System.currentTimeMillis());
          notify.defaults = Notification.DEFAULT_SOUND;
          notify.defaults = Notification.DEFAULT_VIBRATE;
  
      Intent Settings = new Intent(context, WidgetConfigure.class);
      Settings.putExtra(AppWidgetManager.EXTRA_APPWIDGET_ID, appWidgetId);
  
          PendingIntent pending = PendingIntent.getActivity(context, 0, weatherSettings, PendingIntent.FLAG_ONE_SHOT);
          notify.setLatestEventInfo(context, "Weather Update", info, pending);
          notify.flags = Notification.FLAG_AUTO_CANCEL;
          notify.defaults = Notification.DEFAULT_ALL;
          mnotifyManager.notify(WEATHER_NOTIFICATION_ID , notify);
          }
      }   
  </code></pre>