title: Updating app widget using AlarmManager
body: <p>I am trying to update a Widget more frequently than the 30 minute restriction imposed by the 1.6docs. After reading nearly every post in SO, and the developer docs, and various other sources, I thought I had got to a point where i could implement it. And so, I tried, and failed. Since then, I have trawled yet more forums and solutions, and I cannot seem to get it to update.</p>
  
  <p>I have an Update class that sets the AlarmManager:</p>
  
  <pre><code>public class Update extends Service{
  
      @Override
      public void onStart(Intent intent, int startId) {
            String currentTemp = Battery.outputTemp;
            String currentLevel = Battery.outputLevel;
            String currentCard = Battery.outputCard;
            String currentInternal = Battery.memory;
            String currentRam = String.valueOf(Battery.outputRam).substring(0, 3) + "MB";
  
            // Change the text in the widget
            RemoteViews updateViews = new RemoteViews( 
            this.getPackageName(), R.layout.main);
            //update temp
            updateViews.setTextViewText(R.id.batteryTemp, currentTemp); 
            //update %
            updateViews.setTextViewText(R.id.batteryLevel, currentLevel);     
            //update level
            updateViews.setTextViewText(R.id.sdCard, currentCard);
            //update internal memory
            updateViews.setTextViewText(R.id.internal, currentInternal);
            //update ram
            updateViews.setTextViewText(R.id.ram, currentRam);
  
            ComponentName thisWidget = new ComponentName(this, Widget.class);
            AppWidgetManager manager = AppWidgetManager.getInstance(this);
            manager.updateAppWidget(thisWidget, updateViews);
  
      }
      @Override
      public IBinder onBind(Intent intent) {
          // no need to bind
          return null;
      }
  
  }
  </code></pre>
  
  <p>This has caused my onReceive in my widget class to fire frequently (i have a toast to see when it fires), yet it carries no intent (the toast is meant to display this as they are received but it is blank).</p>
  
  <p>I cannot figure it out (i'm a relative newb-2 months of slow android dev), and appreciate any insight you guys have. </p>
  
  <p>heres my widget class for reference:</p>
  
  <pre><code>    public class Widget extends AppWidgetProvider {
  
  
      @Override
      public void onUpdate(Context context, AppWidgetManager appWidgetManager,
              int[] appWidgetIds) {
  
          AlarmManager alarmManager;
          Intent intent = new Intent(context, Update.class);
          PendingIntent pendingIntent = PendingIntent.getBroadcast(context, 0,
                  intent, PendingIntent.FLAG_UPDATE_CURRENT);
          alarmManager = (AlarmManager) context
                  .getSystemService(Context.ALARM_SERVICE);
          Calendar cal = Calendar.getInstance();
          cal.setTimeInMillis(System.currentTimeMillis());
          cal.add(Calendar.SECOND, 10);
          alarmManager.setRepeating(AlarmManager.RTC_WAKEUP, cal
                  .getTimeInMillis(), 5 * 1000, pendingIntent);
  
          String currentTemp = Battery.outputTemp;
          String currentLevel = Battery.outputLevel;
          String currentCard = Battery.outputCard;
          String currentInternal = Battery.memory;
          String currentRam = String.valueOf(Battery.outputRam).substring(0, 3)
                  + "MB";
  
          // Change the text in the widget
          RemoteViews updateViews = new RemoteViews(context.getPackageName(),
                  R.layout.main);
          // update temp
          updateViews.setTextViewText(R.id.batteryTemp, currentTemp);
          appWidgetManager.updateAppWidget(appWidgetIds, updateViews);
          // update %
          updateViews.setTextViewText(R.id.batteryLevel, currentLevel);
          appWidgetManager.updateAppWidget(appWidgetIds, updateViews);
          // update level
          updateViews.setTextViewText(R.id.sdCard, currentCard);
          appWidgetManager.updateAppWidget(appWidgetIds, updateViews);
          // update internal memory
          updateViews.setTextViewText(R.id.internal, currentInternal);
          appWidgetManager.updateAppWidget(appWidgetIds, updateViews);
          // update ram
          updateViews.setTextViewText(R.id.ram, currentRam);
          appWidgetManager.updateAppWidget(appWidgetIds, updateViews);
          super.onUpdate(context, appWidgetManager, appWidgetIds);
  
      }
  
      public void onReceive(Context context, Intent intent) {
  
          super.onReceive(context, intent);
          Toast
                  .makeText(context, intent.getAction() + context,
                          Toast.LENGTH_LONG).show();
          Bundle extras = intent.getExtras();
          if (extras != null) {
              AppWidgetManager appWidgetManager = AppWidgetManager
                      .getInstance(context);
              ComponentName thisAppWidget = new ComponentName(context
                      .getPackageName(), Widget.class.getName());
              int[] appWidgetIds = appWidgetManager
                      .getAppWidgetIds(thisAppWidget);
  
              onUpdate(context, appWidgetManager, appWidgetIds);
          }
  
      }
  }
  </code></pre>