Flutter ranging beacons in background - Android 8.

2020-07-27 16:11发布

问题:

I'm using flutter_beacon for detecting iBeacons in one of my flutter project. Its working fine in foreground and in background for android version below 8. But its not detecting beacons in background for android version 8 and above.

As per background location limits: Android 8.0 (API level 26) limits how frequently background apps can retrieve the user's current location. Apps can receive location updates only a few times each hour.

I've also reported an issue to github with the example code here

Is there any extra code I have to write in order to make android device with version 8+ be able to detect beacons in background ?

回答1:

What you are trying to do is Restricted According to this : https://developer.android.com/about/versions/oreo/background-location-limits

BUT, according to the same doc, you Can do what you need to do only if your app has one of these,

  1. It has a foreground service.
  2. Input method editor (IME)
  3. Wallpaper service
  4. Notification listener
  5. Voice or text service

you can go with 1st or 3rd one but it requires some platform specific coding.