diff --git a/app/build.gradle b/app/build.gradle
index 6d2f8ce11..5baa95f01 100644
--- a/app/build.gradle
+++ b/app/build.gradle
@@ -17,8 +17,8 @@ android {
applicationId "org.thosp.yourlocalweather"
minSdkVersion 14
targetSdkVersion 25
- versionCode 26
- versionName "3.0"
+ versionCode 27
+ versionName "3.0.1"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
vectorDrawables.useSupportLibrary = true
playAccountConfig = playAccountConfigs.defaultAccountConfig
diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml
index 634877a74..723d5667a 100644
--- a/app/src/main/AndroidManifest.xml
+++ b/app/src/main/AndroidManifest.xml
@@ -164,6 +164,7 @@
+
diff --git a/app/src/main/java/org/thosp/yourlocalweather/SettingsActivity.java b/app/src/main/java/org/thosp/yourlocalweather/SettingsActivity.java
index be01e1698..2a81e56ef 100644
--- a/app/src/main/java/org/thosp/yourlocalweather/SettingsActivity.java
+++ b/app/src/main/java/org/thosp/yourlocalweather/SettingsActivity.java
@@ -263,7 +263,7 @@ private void updateSummary(String key, boolean changing) {
case Constants.KEY_PREF_LOCATION_AUTO_UPDATE_PERIOD:
entrySummary(key);
if (changing) {
- Intent intentToStartUpdate = new Intent("org.thosp.yourlocalweather.action.START_ALARM_SERVICE");
+ Intent intentToStartUpdate = new Intent("org.thosp.yourlocalweather.action.RESTART_ALARM_SERVICE");
intentToStartUpdate.setPackage("org.thosp.yourlocalweather");
getActivity().startService(intentToStartUpdate);
}
diff --git a/app/src/main/java/org/thosp/yourlocalweather/service/AppAlarmService.java b/app/src/main/java/org/thosp/yourlocalweather/service/AppAlarmService.java
index 2ae41bce4..126f9d0bb 100644
--- a/app/src/main/java/org/thosp/yourlocalweather/service/AppAlarmService.java
+++ b/app/src/main/java/org/thosp/yourlocalweather/service/AppAlarmService.java
@@ -45,6 +45,9 @@ public int onStartCommand(Intent intent, int flags, final int startId) {
appendLog(getBaseContext(), TAG, "onStartCommand:intent.getAction():" + intent.getAction());
if ("org.thosp.yourlocalweather.action.START_ALARM_SERVICE".equals(intent.getAction())) {
setAlarm();
+ } else if ("org.thosp.yourlocalweather.action.RESTART_ALARM_SERVICE".equals(intent.getAction())) {
+ alarmStarted = false;
+ setAlarm();
} else if ("org.thosp.yourlocalweather.action.START_LOCATION_WEATHER_ALARM".equals(intent.getAction())) {
boolean autoLocation = intent.getBooleanExtra("autoLocation", false);
LocationsDbHelper locationsDbHelper = LocationsDbHelper.getInstance(getBaseContext());
@@ -56,7 +59,7 @@ public int onStartCommand(Intent intent, int flags, final int startId) {
if (autoLocation && !"0".equals(updateAutoPeriodStr)) {
long updateAutoPeriodMills = Utils.intervalMillisForAlarm(updateAutoPeriodStr);
scheduleNextRegularAlarm(true, updateAutoPeriodMills);
- } else {
+ } else if (!"0".equals(updatePeriodStr) && (locationsDbHelper.getAllRows().size() > 1)) {
scheduleNextRegularAlarm(false, updatePeriodMills);
}
@@ -87,6 +90,7 @@ public void setAlarm() {
alarmStarted = true;
cancelAlarm(true);
cancelAlarm(false);
+ sendSensorStopIntent();
LocationsDbHelper locationsDbHelper = LocationsDbHelper.getInstance(getBaseContext());
String updatePeriodStr = AppPreference.getLocationUpdatePeriod(getBaseContext());
String updateAutoPeriodStr = AppPreference.getLocationAutoUpdatePeriod(getBaseContext());
@@ -105,7 +109,7 @@ public void setAlarm() {
scheduleNextRegularAlarm(true, updateAutoPeriodMills);
}
}
- if (!"0".equals(updatePeriodStr) && locationsDbHelper.getAllRows().size() > 1) {
+ if (!"0".equals(updatePeriodStr) && (locationsDbHelper.getAllRows().size() > 1)) {
scheduleNextRegularAlarm(false, updatePeriodMills);
}
}
@@ -154,6 +158,9 @@ private void sendSensorStopIntent() {
Intent sendIntent = new Intent("android.intent.action.STOP_SENSOR_BASED_UPDATES");
sendIntent.setPackage("org.thosp.yourlocalweather");
startService(sendIntent);
+ AlarmManager alarmManager = (AlarmManager) getSystemService(Context.ALARM_SERVICE);
+ alarmManager.cancel(getPendingSensorStartIntent());
+ getPendingSensorStartIntent().cancel();
appendLog(getBaseContext(), TAG, "sendIntent:" + sendIntent);
}
diff --git a/app/src/main/res/values/arrays.xml b/app/src/main/res/values/arrays.xml
index f2195386d..91de2a4bc 100644
--- a/app/src/main/res/values/arrays.xml
+++ b/app/src/main/res/values/arrays.xml
@@ -50,7 +50,6 @@
- - @string/update_period_nothing
- @string/update_period_15min
- @string/update_period_30min
- @string/update_period_1hour
@@ -60,7 +59,6 @@
- @string/update_period_24hours
- - 0
- 15
- 30
- 60
@@ -92,6 +90,7 @@
+ - @string/update_period_nothing
- @string/update_period_15min
- @string/update_period_30min
- @string/update_period_1hour
@@ -101,6 +100,7 @@
- @string/update_period_24hours
+ - 0
- 15
- 30
- 60