AltBeacon / android-beacon-library

Allows Android apps to interact with BLE beacons
Apache License 2.0
2.84k stars 836 forks source link

App cannot be started by RegionBootstrap from background #998

Closed malibu1966 closed 4 years ago

malibu1966 commented 4 years ago

Hi there. I have been trying to use the 'start app in background' example and I am convinced there must be some bug. I have taken this to the extent that I started a new 'drawer-based' example application and only applied the location permission and changes required to make background RegionBootstap monitoring work with a start of MainActivity when the beacon is detected. I did .setDebug on BeaconManager and the beacon is being detected, also the didEnterRegion is being called in my Application class.

Expected behavior

Application starts in foreground

Actual behavior

09-07 11:34:30.359 1386 1544 W BroadcastQueue: Background execution not allowed: receiving Intent { act=android.intent.action.PACKAGE_RESTARTED dat=package:com.example.beacontest flg=0x10 (has extras) } to android/com.kddi.android.CpaNotiReceiver

I'm pretty sure this is the error that is stopping the app from starting. I'm dumping all the logs to a file with adb logcat I run this and could provide the whole thing.

Steps to reproduce this behavior

Install sample drawer based application add beacon library extend Application as per sample modify Manitest as per sample Add check/request for ACCESS_FINE_LOCATION and ACCESS_BACKGROUND_LOCATION

Mobile device model and OS version

Samsung Note 9 with default launcher Android version 10 kernel 4.9.186-18803994

Android Beacon Library version

2.17.1

IMPORTANT: This forum is reserved for feature requests or reproducible bugs with the library itself. If you need help with using the library with your project, please open a new question on StackOverflow.com.

davidgyoung commented 4 years ago

@malibu1966, can you please try to reproduce this problem with the reference app? https://github.com/AltBeacon/android-beacon-library-reference If you can reproduce with that app as-is, or with a slightly modified version for which you can share a diff, we can help track down the issue in this forum. If you want help debugging your custom app, the proper forum for help is stackoverflow.com.

malibu1966 commented 4 years ago

I tried the library reference. The one modification I made was to scan for iBeacons:

beaconManager.getBeaconParsers().add(new BeaconParser().
                setBeaconLayout("m:2-3=0215,i:4-19,i:20-21,i:22-23,p:24-24"));

I am getting the same error:

09-07 22:57:07.151 1424 1618 W BroadcastQueue: Background execution not allowed: receiving Intent { act=android.intent.action.PACKAGE_RESTARTED dat=package:org.altbeacon.beaconreference flg=0x10 (has extras) } to android/com.kddi.android.CpaNotiReceiver

The intent gets called but there is never any sign of MonitoringActivity executing afterwards.

malibu1966 commented 4 years ago

Why was this closed?

davidgyoung commented 4 years ago

@malibu1966, this was closed as of my initial comment because the steps to reproduce are about building a custom app, which makes it out of scope for this forum. I do see your comment above about doing a test with the reference app. Please open a new issue that describes the specific problem you see with the reference app and steps to reproduce (e.g. launch app in foreground, turn on a beacon with identifier XXX, wait X minutes for a didEnerRegion callback, etc.) An operating system log message is not necessarily unexpected behavior. What is the functional behavior that you see that is unexpected?