title: Android service run every 10 seconds makes ANR Message
body: <p>I have an android application, which contains a main activity which displays information to the user.</p>
  
  <p>When MainActivity starts, A service is created/started which checks a web service on every 10 seconds - if the Web service result will show in a notification.</p>
  
  <p>I start the service from Main activity using Intent,</p>
  
  <pre><code>getActivity().startService(new Intent(getActivity(), NotificationService.class));
  </code></pre>
  
  <p>I Also try this code, (But same result).</p>
  
  <pre><code>getActivity().runOnUiThread(new Runnable() {
      @Override
      public void run() {
          getActivity().startService(new Intent(getActivity(), NotificationService.class));
      }
  });
  </code></pre>
  
  <p>If service started I get warning In my Logcat,</p>
  
  <p><strong>Skipped 91 frames! The application may be doing too much work on its main thread.</strong></p>
  
  <p>My notification service code,</p>
  
  <pre><code> public class NotificationService extends Service {
  // constant
  public static final long NOTIFY_INTERVAL = 10 * 1000; // 10 seconds
  long current_times;
  String c_time;
  // run on another Thread to avoid crash
  private Handler mHandler = new Handler();
  // timer handling
  static HttpClient client = new DefaultHttpClient();
  private Timer mTimer = null;
  
  @Override
  public int onStartCommand(Intent intent, int flags, int startId) {
      // TODO Auto-generated method stub
      return START_STICKY;
  }
  
  @Override
  public IBinder onBind(Intent intent) {
      return null;
  }
  
  @TargetApi(Build.VERSION_CODES.GINGERBREAD) @SuppressLint("NewApi") @Override
  public void onCreate() {
      // cancel if already existed
  
      StrictMode.ThreadPolicy policy = new StrictMode.ThreadPolicy.Builder().permitAll().build();
      StrictMode.setThreadPolicy(policy);
      SharedPreferences.Editor editor = getSharedPreferences("notification_oldtime", MODE_PRIVATE).edit();
  
       editor.putInt("old_trail_time", 0);
       editor.putInt("old_sample_time", 0);
       editor.putInt("old_neworder_time", 0);
  
       editor.commit();
  
      if(mTimer != null) {
          mTimer.cancel();
      } else {
          // recreate new
          mTimer = new Timer();
      }
      // schedule task
      mTimer.scheduleAtFixedRate(new TimeDisplayTimerTask(), 0, NOTIFY_INTERVAL);
  }
  
  public long current_time_get(){
  
      return current_times;
  
  }
  
  
  
  
  
  class TimeDisplayTimerTask extends TimerTask {
  
      @TargetApi(Build.VERSION_CODES.JELLY_BEAN) @Override
      public void run() {
          // run on another thread
  
          mHandler.post(new Runnable() {
  
              @Override
              public void run() {
                  // My webservice code for notification
                }
  
          }
         }
  </code></pre>