title: Widget ImageView not updating
body: <p>I am trying to make a clock widget in which I have a ImageView with custom font.</p>
  
  <p>Here is the code by which I am updating the widget in 1 sec interval.</p>
  
  <p>[code]</p>
  
  <pre><code>package com.coderzheaven.customfontinwidget;
  
  import java.util.Calendar;
  import java.util.TimerTask;
  
  import android.appwidget.AppWidgetManager;
  import android.content.ComponentName;
  import android.content.Context;
  import android.graphics.Bitmap;
  import android.graphics.Canvas;
  import android.graphics.Color;
  import android.graphics.Matrix;
  import android.graphics.Paint;
  import android.graphics.Paint.Align;
  import android.graphics.Typeface;
  import android.os.Handler;
  import android.widget.RemoteViews;
  
  public class MyTimer extends TimerTask {
      RemoteViews remoteViews;
      static Context thisContext;
      AppWidgetManager appWidgetManager;
      ComponentName thisWidget;
      Handler mHandler;
  
      public MyTimer(Context context, AppWidgetManager appWidgetManager) {
          this.appWidgetManager = appWidgetManager;
          MyTimer.thisContext = context;
  
          remoteViews = new RemoteViews(thisContext.getPackageName(),
                  R.layout.widget_main);
  
          thisWidget = new ComponentName(context, MyAppWidgetProvider.class);
  
          mHandler = new Handler();
  
          System.out.println("TIMER STARTED................");
  
      }
  
      @Override
      public synchronized void run() {
  
          int[] allWidgetIds = appWidgetManager.getAppWidgetIds(thisWidget);
  
          for (final int appWidgetId : allWidgetIds) {
  
              if (mHandler != null) {
  
                  mHandler.post(new Runnable() {
                      public void run() {
  
                          System.out.println("UPDATING......" + getTodaysTime() + " ID = " + appWidgetId);
  
                          Bitmap bmp = buildUpdate(getTodaysTime());
  
                          setBitmap(remoteViews, R.id.imageView_txt, bmp);
  
                          appWidgetManager.updateAppWidget(appWidgetId,
                                  remoteViews); 
  
                      }
                  }
  
                  );
  
              }
  
          }
  
      } 
  
  
  
      public static Bitmap buildUpdate(String time) {
          Bitmap myBitmap = Bitmap.createBitmap(250, 250, Bitmap.Config.ARGB_8888);
          Canvas myCanvas = new Canvas(myBitmap);
          Paint paint = new Paint();
          Typeface clock = Typeface.createFromAsset(thisContext.getAssets(),
                  "digital-7.ttf");
          paint.setAntiAlias(true);
          paint.setSubpixelText(true);
          paint.setTypeface(clock);
          paint.setStyle(Paint.Style.FILL);
          paint.setColor(Color.RED);
          paint.setTextSize(60);
          paint.setTextAlign(Align.CENTER);
          myCanvas.drawText(time, 120, 60, paint);
          return myBitmap;
      }
  
      private void setBitmap(RemoteViews views, int resId, Bitmap bitmap){
          Bitmap proxy = Bitmap.createBitmap(bitmap.getWidth(), bitmap.getHeight(), Bitmap.Config.ARGB_8888);
          Canvas c = new Canvas(proxy);
          c.drawBitmap(bitmap, new Matrix(), null);
          views.setImageViewBitmap(resId, proxy);
      }
  
      public static String getTodaysTime() {
          final Calendar c = Calendar.getInstance();
          int hour = c.get(Calendar.HOUR_OF_DAY);
          int minute = c.get(Calendar.MINUTE);
          int seconds = c.get(Calendar.SECOND);
          return new StringBuilder().append(pad(hour)).append(":")
                  .append(pad(minute)).append(":").append(pad(seconds)).toString();
      }
  
      private static String pad(int c) {
          if (c &gt;= 10)
              return String.valueOf(c);
          else
              return "0" + String.valueOf(c);
      }
  }
  </code></pre>
  
  <p>[/code]</p>
  
  <p>But my problem is the the time is updated only once.
  I can't find a solution.</p>
  
  <p>This is my AppWidgetProviderClass
  [code]</p>
  
  <pre><code>package com.coderzheaven.customfontinwidget;
  
  import java.util.Timer;
  
  import android.appwidget.AppWidgetManager;
  import android.appwidget.AppWidgetProvider;
  import android.content.Context;
  import android.content.Intent;
  
  public class MyAppWidgetProvider extends AppWidgetProvider {
      static Timer myTimer;
      Intent myIntent;
      MyTimer obj_MyTime;
  
      @Override
      public void onUpdate(Context context, AppWidgetManager appWidgetManager,
              int[] appWidgetIds) {
          System.out.println("onUpdate");
          startTimer(context);
      }
  
      void startTimer(Context context) {
          if (myTimer != null) {
              myTimer.cancel();
          }
          myTimer = new Timer();
          if (obj_MyTime == null)
              obj_MyTime = new MyTimer(context,
                      AppWidgetManager.getInstance(context));
          myTimer.scheduleAtFixedRate(obj_MyTime, 1, 1000);
      }
  
      /*
       * This is called when an instance the App Widget is created for the first
       * time.
       */
      @Override
      public void onEnabled(Context context) {
          startTimer(context);
          super.onEnabled(context);
      }
  
      /*
       * This is called for every broadcast and before each of the above callback
       * methods.
       */
      @Override
      public void onReceive(Context context, Intent intent) {
          super.onReceive(context, intent);
      }
  
      /* 
       * This is called When all instances of App Widget is deleted from the App
       * Widget host.
       */
      @Override 
      public void onDisabled(Context context) {
          System.out.println("All Widgets Deleted");
          // disposeWidget();
          super.onDisabled(context);
      }  
  
      /*
       * This is called every time an App Widget is deleted from the App Widget
       * host.
       */
      @Override
      public void onDeleted(Context context, int[] appWidgetIds) {
          super.onDeleted(context, appWidgetIds);
      }
  
      public void disposeWidget() {
          if (myTimer != null) {
              myTimer.cancel();
              // myTimer.notifyAll();
              myTimer = null;
          }
          if (obj_MyTime != null) {
              obj_MyTime.cancel();
              // obj_MyTime.notifyAll();
              obj_MyTime = null;
          }
      }
  }
  </code></pre>
  
  <p>[/code]</p>