gelin / weather-notification

An utility which displays the weather in the Android notification bar
GNU General Public License v3.0
26 stars 11 forks source link

Scheduled update not working #60

Closed oweppe closed 3 years ago

oweppe commented 4 years ago

Hi,

I noticed the auto-update is not running properly with 0.3.11: The notification is displayed, but is never refreshed. Once I tap the notification, the popup window appears and the weather info is being refreshed almost instantly (proving this is not a communication issue with openweather).

Battery optimization disabled, backgroup running enabled, nothing seem to revive the scheduling.

Android 10 Samsung OneUI.

Thanks for this great app!

birdwing commented 3 years ago

I believe the issue is with Location services.

Currently weather-notification on Android 10 does not ask for: "ACCESS_BACKGROUND_LOCATION" So you can only set the location permission to "Allow only while the App is in use" or "Deny"

I'm not sure if the notification being displayed is enough for android to consider the app "In Use" for updating a users location.

So if you do not have a "Manual" location set, Weather Notification is not able to get your location, and therefore cannot update the weather.

birdwing commented 3 years ago

I believe I have confirmed this

I am running a Google Pixed 3XL with Android 10 I have set Battery Optimization for Weather Notifications to Don't Optimize.

The weather does not auto update if I have Weather Notifications Detect Location set to By GPS satallites or By cellular or Wi-Fi network.

If I change Detect Location to Manually and set a location, then the weather updates properly in the background. This points to Weather Notifications not being able to get a users location in the background.

I believe that ACCESS_BACKGROUND_LOCATION must be added to the manifest.xml file.


If you don't know how to turn off Battery Optimization

  1. Open up android settings and go to Apps & Notifications
  2. Tap on Advanced
  3. Tap on Special app access
  4. Tap on Battery optimization
  5. The dropdown will default to Not optimized
    • This is a list of apps that are not optimized, meaning android will not limit their functionality to save battery when they are in the background.
    • Check to see if Weather Notifications is on this list. If it is you are done. Otherwise continue to step 6.
  6. Tap on the dropdown and change it to All apps.
  7. Scroll down until you find Weather Notifications and tap on it.
  8. In the alert that pops up set it to Don't Optimize and tap done.
oweppe commented 3 years ago

Yes I can confirm too that the refresh works fine when I switch to manual location.

y0grt commented 3 years ago

Same for Xiaomi MIUI 12. No ACCESS_BACKGROUND_LOCATION permission requested. Auto-update only works with manual location.

gelin commented 3 years ago

Fixed here: https://github.com/gelin/weather-notification/commit/07614c698b564744c8f573e877a886bc6589b5d4

Going to be released in v0.3.13.