public void run() { int timedCount = 0; while (!Thread.interrupted()) { try { Thread.sleep(SEC_POLL_DELAY); } catch (InterruptedException e) { break; } // 5400 seconds = 90 min if (timedCount == 5400) { timedCount = 0; Intent dialogIntent = new Intent(getBaseContext(), BlockerActivity.class); dialogIntent.addFlags( Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK); dialogIntent.putExtra( "AlertInfo", "You've used your phone for 90 minutes NON-STOP. Please take a break!"); getApplication().startActivity(dialogIntent); } timedCount++; synchronized (mPauseLock) { while (mPaused) { try { mPauseLock.wait(); } catch (InterruptedException e) { e.printStackTrace(); } } } } }