title: Canvas not updating in real device
body: <p>I trying to make a draw line using canvas. It has 0 value when the Activity is loaded then I have a Button that has click listener to change the value and draw a line. It works in emulator well but when I run in my real device (android version 4.1) the canvas didn't change but I know that I hit the button because I put a toast inside the click listener. This is really weird.</p>
  
  <p>Do anyone encounter the same problem before?
  any thoughts will be highly appreciated.</p>
  
  <p>Below is my Activity:</p>
  
  <pre><code>public class MainActivity extends Activity{
  
      private Paint paintFree = new Paint();
      private Paint paintLocal = new Paint();
      private Paint paintRoaming = new Paint();
  
      private int freeUsage = 0;
      private int localUsage = 0;
      private int roamingUsage = 0;
  
      private int freeBarPoints;
      private int localBarPoints;
  
      @Override
      protected void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          setContentView(R.layout.main);
          overridePendingTransition(0, 0);
          line();
  
          ((Button) findViewById(R.id.btn1)).setOnClickListener(new View.OnClickListener() {
  
              @Override
              public void onClick(View v) {
                  // TODO Auto-generated method stub
                  freeUsage = 12;
                  localUsage = 1;
                  roamingUsage = 1;
                  line();
                  Log.i("Hit Btn1", "True");
                  Toast.makeText(v.getContext(), "Hit Btn1", Toast.LENGTH_SHORT).show();
              }
          });
  
      }
  
      class Draw extends View{
  
          public Draw(Context context) {
              super(context);
              // TODO Auto-generated constructor stub
  
              paintFree.setStrokeWidth(20f);
              paintLocal.setStrokeWidth(20f);
              paintRoaming.setStrokeWidth(20f);
  
               if (freeUsage == 0){
                      paintFree.setColor(Color.GRAY);
                  } else {
                      paintFree.setColor(Color.rgb(70, 227, 78));
                  }
                  if (localUsage == 0){
                      paintLocal.setColor(Color.GRAY);
                  } else {
                      paintLocal.setColor(Color.rgb(238, 232, 102));
                  }
                  if (roamingUsage == 0){
                      paintRoaming.setColor(Color.GRAY);
                  } else {
                      paintRoaming.setColor(Color.rgb(101, 177, 231));
                  }
  
          }
  
          protected void onDraw(Canvas canvas) {
  
              int maxBarLength = canvas.getWidth() * 4 / 5;
              double totalBarPoints = freeUsage + localUsage + roamingUsage;  
              freeBarPoints = (int) Math.round(freeUsage * maxBarLength / totalBarPoints);
              localBarPoints = (int) Math.round(localUsage * maxBarLength / totalBarPoints);
              // need not compute the roaming bar points  
  
              int localStartX = 0 + Math.round(freeBarPoints);
              int roamingStartX = (int) localStartX + Math.round(localBarPoints);
  
              canvas.drawLine(0, 10, localStartX, 10, paintFree);
              canvas.drawLine(localStartX, 10, roamingStartX, 10, paintLocal);
              canvas.drawLine(roamingStartX, 10, maxBarLength, 10, paintRoaming);
          }
  
  
      }
  
      public void line(){
          Draw draw;
          draw = new Draw(this);
          ((LinearLayout) findViewById(R.id.linear)).addView(draw);   
      }
  
  }
  </code></pre>