title: Android - widget breaks after launcher reload/crash
body: <p>I've made an Android home screen widget which displays some text and has 2 click listeners which I have working under normal operation, no problems. That is until HTC sense/launcher decides to reload, which it does most days. After the reload one of the click listeners stops working and can cause the widget to Force Close.</p>
  
  <p>onClickListener 1 = starts an activity and passes it some text strings</p>
  
  <p>onClickListener 2 = Triggers FORCE_WIDGET_UPDATE</p>
  
  <p>After a launcher reload, the activity still trigures fine, but the widget update fails.</p>
  
  <p>Here is the essence of the update code.</p>
  
  <pre><code>public static String updateString = "org.software.appname.FORCE_WIDGET_UPDATE";
  public void onReceive(Context ctx, Intent intent){
          showIntent=intent.getAction();
          Log.d(TAG, showIntent);
          if (updateString.equals(intent.getAction())){
  
              Log.d(TAG, "onReceive, Force");
          AppName.updateViews = new RemoteViews( ctx.getPackageName(),R.layout.main );
  
              &lt;Code to update text, update widget view and load new intents&gt;
  
          ComponentName me = new ComponentName( ctx, AppName.class );
              AppWidgetManager.getInstance( ctx ).updateAppWidget( me, updateViews );
  
          } else super.onReceive(ctx, intent);
  </code></pre>
  
  <p>I've tried moving the onRecieve call to the super class inside the if statement, but this causes the app to force close as soon you the widget is dropped onto the home screen.</p>
  
  <p>I don't see anything in logcat when clicking the button, when I normally would, sometimes it force closes sometimes it doesn't. I can re-create the problem in the desktop simulator by force closing the stock launcher in application setting.</p>
  
  <p>Thanks in advance for your help! :-)</p>
  
  <p>Edit:
  I've tried changing things around by passing appWidgetIds[] in the intent and then triggering the onUpdate within onReceive, but this doesn't seem to do anything. I get the message in logcat to say it's registering the click, but it doens't seem to be triggering onUpdate.</p>
  
  <pre><code>public void onReceive(Context ctx, Intent intent){
          AppWidgetManager appWidgetManager = AppWidgetManager.getInstance(ctx);
          int[] appWidgetIds = intent.getIntArrayExtra("appWidgetIds");
          onUpdate(ctx, appWidgetManager, appWidgetIds);
          Log.d(TAG, "onReceive log");
  }
  </code></pre>