Skip to content

Instantly share code, notes, and snippets.

@parahall
Created May 10, 2018 17:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save parahall/4589e6a7920678300ee727f64333ff19 to your computer and use it in GitHub Desktop.
Save parahall/4589e6a7920678300ee727f64333ff19 to your computer and use it in GitHub Desktop.
public class LocationWork extends Worker {
...
public WorkerResult doWork() {
Log.d(TAG, "doWork: Started to work");
handlerThread = new HandlerThread("MyHandlerThread");
handlerThread.start();
looper = handlerThread.getLooper();
locationTracker = new LocationTracker(getApplicationContext(), looper);
locationTracker.start();
try {
locationWait = new CountDownLatch(1);
locationWait.await();
Log.d(TAG, "doWork: Countdown released");
} catch (InterruptedException e) {
Log.d(TAG, "doWork: CountdownLatch interrupted");
e.printStackTrace();
}
cleanUp();
return WorkerResult.SUCCESS;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment