Guest User

Untitled

a guest
Mar 12th, 2013
170
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.26 KB | None | 0 0
  1. class checkAyscTask implements Runnable {
  2.  
  3.         AsyncTask<Void, Void, Boolean> mAT;
  4.  
  5.         Context context;
  6.  
  7.         public checkAyscTask(AsyncTask<Void, Void, Boolean> at, Context context) {
  8.             mAT = at;
  9.             this.context = context;
  10.  
  11.         }
  12.  
  13.         public checkAyscTask(GetGPShotfix task_GetGPS) {
  14.             //m2AT = task_GetGPS;
  15.             // TODO Auto-generated constructor stub
  16.         }
  17.  
  18.         @Override
  19.         public void run() {
  20.             mHandler.postDelayed(runnable, 10000);// After 60sec the task in run() of //runnable will be done
  21.  
  22.         }
  23.  
  24.         Handler mHandler = new Handler();
  25.         Runnable runnable = new Runnable() {
  26.  
  27.             @Override
  28.             public void run() {
  29.                 if (mAT.getStatus() == Status.RUNNING || mAT.getStatus() == Status.PENDING) {
  30.                     mAT.cancel(true);//Cancel Async task or do the operation //you want after 1 minute
  31.                     System.out.println("after 10 secs?");
  32.                     }};
  33.     };
  34.         }
  35.  
  36.  
  37. // here's how am calling this:
  38. //onClickListener()
  39. GetGPShotfix task_GetGPS = new GetGPShotfix();
  40. task_GetGPS.execute();
  41. checkAyscTask chk = new checkAyscTask(task_GetGPS); // Thread keeping 1 minute time watch
  42. (new Thread(chk)).start();
Advertisement
Add Comment
Please, Sign In to add comment