title: Android Widget stops working randomly
body: <p>I have been working with this problem for three days now and I've looked at every single question on here for an answer. I have a widget with a button on it and all I would like it to do is start a service everytime it is clicked. The problem is that the button stops working randomly. I can't recreate it at all and I have no idea what causes it. My service calls stopSelf(); but I have had this problem with a broadcast receiver also so I believe the problem to be in the widget and not in the service. Here is the code</p>
  
  <pre><code>public void onUpdate(Context context, AppWidgetManager appWidgetManager, int[]     appWidgetIds) 
  {
  
  Log.i("Widget", "onUpdate");
  
  final int N = appWidgetIds.length;
  
      for (int i=0; i&lt;N; i++) 
      {
  
          int appWidgetId = appWidgetIds[i];
  
          Log.i("Widget", "onUpdateLoop");
  
  
          Intent intent = new Intent(context, ServiceWidgetAction.class);
          intent.setAction(Long.toString(System.currentTimeMillis()));
          intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
  
          PendingIntent pendingIntent = PendingIntent
                  .getService(context, 0, intent, PendingIntent.FLAG_UPDATE_CURRENT);
  
          RemoteViews views = new RemoteViews(context.getPackageName(), 
                 R.layout.widget);
  
          views.setOnClickPendingIntent(R.id.widgetButton, pendingIntent);
  
          views.setTextViewText(
                  R.id.widgetTextView,
                  "Some text");
  
          appWidgetManager.updateAppWidget(appWidgetId, views);
  
      }
  
  }
  </code></pre>
  
  <p>I've checked this code over and over and I have no idea why it is doing this. It does this on 3 separate phones and I can't recreate it. I've tried force stopping the app, clearing it from a task manager adding new widgets etc. to get the widget to stop working and it won't. However when I woke up this morning the widget no longer works. Any help would be GREATLY appreciated.</p>