From 3fd04b220d12a1545b210ae961b7bbf6ce5d02be Mon Sep 17 00:00:00 2001 From: Marcin Jedynski Date: Fri, 21 Sep 2018 00:09:47 +0200 Subject: [PATCH] added workmanager background location updates, but not sending to API --- app/build.gradle | 3 ++ app/src/main/AndroidManifest.xml | 2 +- .../findmytutor/activity/MainActivity.java | 14 +++++- .../findmytutor/utils/LocationPushWorker.java | 49 +++++++++++++++++++ 4 files changed, 66 insertions(+), 2 deletions(-) create mode 100644 app/src/main/java/com/uam/wmi/findmytutor/utils/LocationPushWorker.java diff --git a/app/build.gradle b/app/build.gradle index a333d4f..d457145 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -45,4 +45,7 @@ dependencies { implementation "com.squareup.okhttp3:okhttp:3.11.0" implementation "com.squareup.okhttp3:okhttp-urlconnection:3.10.0" implementation "com.squareup.okhttp3:logging-interceptor:3.11.0" + implementation "android.arch.work:work-runtime:1.0.0-alpha09" + implementation "com.google.android.gms:play-services-location:15.0.1" + } diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index 55a5adf..4b477db 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -9,7 +9,7 @@ - + () { + @Override + public void onSuccess(Location location) { + // Got last known location. In some rare situations this can be null. + if (location != null) { + // Logic to handle location object + Log.d("LocationUpload", "Location updated: long -> " + location.getLongitude() + "latit - >"+ location.getLatitude()); + + } + } + }); + } + catch(SecurityException e){ + Log.d("LocationException","Location not sent due to perrmision exception "); + return Result.FAILURE; + } + return Result.SUCCESS; + } +}