Android Widget not working after reboot
<blockquote>
  <p><strong>Possible Duplicate:</strong><br>
  <a href="http://stackoverflow.com/questions/9231495/why-widget-does-not-work-after-reboot">Why widget does not work after reboot?</a>  </p>
</blockquote>



<p>i have an appwidget which is updated periodically through a service. Now when the system is rebooted, the appwidget does not show anymore or respond to click service. I try to start the service through the use of a broadcast receiver but no luck so far. what could be wrong?..</p>

<p>here is BroadcastReceiver: </p>

<pre><code>    public void onReceive(final Context context, Intent intent) {
        Log.d(TAG, "received boot completed broadcast receiver... starting service");
        mycontext = context;
        String action = intent.getAction();

        if(action.equals(Intent.ACTION_BOOT_COMPLETED)){

        int[] allids = AppWidgetManager.getInstance(context).getAppWidgetIds(new ComponentName(context, WeatherWidgetProvider.class));
        for(int appWidgetId:allids){

            Intent weatherSettings = new Intent(context, WeatherService.class);
             weatherSettings.putExtra(AppWidgetManager.EXTRA_APPWIDGET_ID, appWidgetId);
             mycontext.startService(weatherSettings);

        }
    }   
  }
</code></pre>

<p>this is how i retrieve the appwidget from the service:</p>

<pre><code> public void onStart(Intent intent, int startId){

         context = getApplicationContext();

      if(intent.getExtras()!= null){
      appWidgetId = intent.getExtras().getInt(AppWidgetManager.EXTRA_APPWIDGET_ID); //get this here, also from the configuration class

   }

      RemoteViews remoteView = new RemoteViews(getApplicationContext().getPackageName(), R.layout.weather_appwidget);
      AppWidgetManager appWidgetManager = AppWidgetManager.getInstance(getApplicationContext());

      /*get sharedPreferences Value*/
      prefs = context.getSharedPreferences(WeatherForecastConfigure.WEATHER_PREF_NAME, MODE_WORLD_READABLE);

      city = prefs.getString(CITY + appWidgetId,"nothing");
      chk_celsius = prefs.getBoolean(CHECKED_CELSIUS + appWidgetId, true);
      updateRate = WeatherForecastConfigure.convertToMillis(prefs.getInt(REFRESH_UPDATE + appWidgetId, 1));

             //web service call and update the widget here    
     }
</code></pre>

<p>I am getting the appwidgetId also from the configurations class, so i don't know if i should be specifying a different intent action. Thank you.</p>
