From a744c4d783675ea1cb22e795158ae2474048ce8a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mieszko=20Wrzeszczy=C5=84ski?= Date: Wed, 28 Nov 2018 09:21:41 +0100 Subject: [PATCH] Improve BG --- app/build.gradle | 2 +- app/src/main/AndroidManifest.xml | 2 + .../findmytutor/activity/BaseActivity.java | 8 +++- .../BackgroundLocalizationService.java | 38 ++----------------- 4 files changed, 12 insertions(+), 38 deletions(-) diff --git a/app/build.gradle b/app/build.gradle index b0c0d7b..33d3488 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -8,7 +8,7 @@ android { } defaultConfig { applicationId "com.uam.wmi.findmytutor" - minSdkVersion 22 + minSdkVersion 23 targetSdkVersion 27 versionCode 5 versionName "0.9.0-alpha" diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index aae98e5..c294244 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -15,6 +15,8 @@ + + providers = new ArrayList(); LocationListener[] mLocationListeners; @@ -78,12 +71,6 @@ public class BackgroundLocalizationService extends Service { private Runnable mStatusChecker; private FusedLocationProviderClient mFusedLocationClient; - PowerManager pm; - PowerManager.WakeLock wl; - - public Handler handler = null; - public static Runnable runnable = null; - public BackgroundLocalizationService() { providers.add(LocationManager.GPS_PROVIDER); providers.add(LocationManager.NETWORK_PROVIDER); @@ -94,7 +81,6 @@ public class BackgroundLocalizationService extends Service { new LocationListener(LocationManager.NETWORK_PROVIDER), new LocationListener(LocationManager.PASSIVE_PROVIDER) }; - } @Override @@ -103,24 +89,13 @@ public class BackgroundLocalizationService extends Service { } - @SuppressLint({"MissingPermission", "InvalidWakeLockTag"}) @Override public int onStartCommand(Intent intent, int flags, int startId) { Log.e(TAG, "onStartCommand"); super.onStartCommand(intent, flags, startId); - try { - pm = (PowerManager) getApplicationContext().getSystemService(Context.POWER_SERVICE); - wl = pm.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, "MyWakeLock"); - wl.acquire(); - wl.release(); - - } catch (Exception ignored) { - - } - if (intent != null) { stopService = intent.getBooleanExtra("request_stop", false); } @@ -138,10 +113,6 @@ public class BackgroundLocalizationService extends Service { @Override public void onCreate() { -// when you done - - - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) startMyOwnForeground(); else { @@ -186,9 +157,6 @@ public class BackgroundLocalizationService extends Service { handler.postDelayed(runnable, 15000); } - - - }