title: Cant change ImageView resource on RemoteView Android
body: <p>I'm trying yo make a simple widget with clickable image that will change when its clicked.
  I don't understand why it doesn't work</p>
  
  <pre><code>   public class AppWidget extends AppWidgetProvider {
  
  @Override
  public void onReceive(Context context, Intent intent) {
  if (intent.getAction()==null) {
      context.startService(new Intent(context,
              ToggleService.class));
  
  } else {
  super.onReceive(context, intent);
  }
  
  }
  @Override
  public void onUpdate(Context context, AppWidgetManager
  appWidgetManager, int[] appWidgetIds) {
      context.startService(new Intent(context, 
              ToggleService.class)); 
  
  }
  public static class ToggleService extends IntentService { 
      public ToggleService() { 
          super("AppWidget$ToggleService");
      }
      @Override
      protected void onHandleIntent(Intent intent) {
      ComponentName me=new ComponentName(this, AppWidget.class);
      AppWidgetManager mgr=AppWidgetManager.getInstance(this);
      mgr.updateAppWidget(me, buildUpdate(this));
      }
      private RemoteViews buildUpdate(Context context) {
      RemoteViews updateViews=new
      RemoteViews(context.getPackageName(),R.layout.widget);
      int a = 1;
      if(a ==
              1) {
  
              updateViews.setImageViewResource(R.id.phoneState,
              R.drawable.dual_off);
      } else {
      updateViews.setImageViewResource(R.id.phoneState,
      R.drawable.dual_on);
      }
      Intent i=new Intent(this, AppWidget.class);
      PendingIntent pi = PendingIntent.getBroadcast(context, 0, i,0); 
      updateViews.setOnClickPendingIntent(R.id.phoneState,pi); 
      return updateViews; 
      }
  }
  
  
  
  
   }
  </code></pre>
  
  <p>I have tried all sort of things in <strong>for</strong> loop but it just won't change image.
  I have done this from a book about android development, am new to java and android.</p>