AltBeacon / android-beacon-library-reference

A reference application for the Android Beacon Library
Apache License 2.0
275 stars 187 forks source link

Modernize behavior on background detection #62

Closed davidgyoung closed 4 years ago

davidgyoung commented 4 years ago

This modernizes the reference app to work properly with Android O+ on background detections.

While the Android Beacon Library has always supported the latest Android versions for background detections, this reference app has not always been updated to demonstrate the library behaviors in the newest Android versions. This change corrects that in two ways:

  1. It uses Notification Channels properly so that notifications appear on devices with Android O and higher.
  2. It no longer tires to auto-launch an activity from the background on first-time beacon detection as this is no longer possible as of Android O.

The new background behavior is that it will send a notification whenever we enter the beacon region. Tapping on that notification will launch the app UI.

If you wan to test a fast detection in the background, try this:

  1. Run this app.
  2. Turn on a beacon so you get a region entry
  3. Turn off a beacon and wait to get a region exit
  4. Kill the app
  5. Turn on the beacon, and watch for a quick notification!