title: Android Is It possible to use Thread.sleep(60000) without getting ANR
body: <p>I am trying to create one application which checks battery status every one minute and update the UI with the battery Level.</p>
  
  <pre><code>protected void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.activity_my);
      batteryPercent = (TextView) this.findViewById(R.id.battery);
      while (true) {
          runOnUiThread(mRunnable);
      }
  }
  
  private Runnable mRunnable = new Runnable() {
      @Override
      public void run() {
          getBatteryPercentage();
  
          try {
              Thread.sleep(60000);
          } catch (InterruptedException e) {
              e.printStackTrace();
          }
      }
  };
  </code></pre>
  
  <p>`getBatteryPercentage()1 update a text view on UI. </p>
  
  <p>When I call <code>getBatteryPercentage()</code> only once the code works fine, but when I try to run it in a loop like above, after few seconds I get Application Not Responding(ANR). </p>
  
  <p>Is there any way to make the app wait for 60 seconds without getting ANR?</p>