Advertisement
luck-alex13

tick OMG

Apr 24th, 2019
176
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.10 KB | None | 0 0
  1.  childProcess = new Thread(new Runnable() {
  2.                 public void run() {
  3.                     // Пока активен
  4.                     while( ! childProcess.isInterrupted()){
  5.  
  6.                         try {
  7.                             // что-то делаем
  8.                             check();
  9.                         } catch(Exception e){
  10.                             e.printStackTrace();
  11.  
  12.                             // show message to user
  13.                             handleMessage(e, MSG_ERROR);
  14.                         }
  15.  
  16.                         try {
  17.                             Thread.sleep(1000);
  18.                         } catch(InterruptedException e){
  19.                             e.printStackTrace();
  20.                             break;
  21.                         }
  22.  
  23.                     }
  24.  
  25.                     // Пометка об остановки
  26.                     getPref().edit().putBoolean("launched", false).commit();
  27.  
  28.                     onServiceStoped();
  29.  
  30.                     stopForeground(true);
  31.                     stopSelf();
  32.                 }
  33.             });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement