Advertisement
Guest User

Untitled

a guest
Sep 21st, 2014
150
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.68 KB | None | 0 0
  1. ...
  2.  
  3. private boolean running;
  4.  
  5. @Override
  6. protected void onCreate(Bundle savedInstanceState) {
  7. super.onCreate(savedInstanceState);
  8.  
  9. running = true;
  10. new Thread(null, work, "myThread").start();
  11. }
  12.  
  13. Runnable work = new Runnable() {
  14.  
  15. @Override
  16. public void run() {
  17. while (running) {
  18. //Doing work
  19. }
  20. }
  21. };
  22.  
  23. @Override
  24. protected void onPause() {
  25. running = false;
  26. super.onPause();
  27. }
  28.  
  29. @Override
  30. protected void onResume(){
  31. running = true;
  32. super.onResume();
  33. }
  34.  
  35. Runnable work = new Runnable() {
  36.  
  37. @Override
  38. public void run() {
  39. while () {
  40. if(running){
  41. //Doing work
  42. }
  43. }
  44. }
  45. };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement