Roven
Roven

Reputation: 7

Android beacon library: how to disable run at startup

It seems that importing android beacon library (2.9) aar file force an application to have "run at startup" permission (adds a receiver in the manifest: org.altbeacon.beacon.startup.StartupBroadcastReceiver)

A test app who wants detect beacon when in foreground only and do not needs run at startup can disable it (and avoid to ask user for the run at startup permission)?

Upvotes: 0

Views: 721

Answers (1)

davidgyoung
davidgyoung

Reputation: 64961

It is true that the Android Beacon Library will start background scanning at startup of the phone, but only if your app constructs a RegionBootstrap object in a the onCreate method of a custom Application class. This feature is not new as of 2.9 -- it has been around since 2.0. You can read about how this works here.

There are two ways to disable this behavior, depending on the specifics of what you want to disable:

  1. If you simply do not want the library to scan for beacons on phone startup, simply do not construct a RegionBootstrap.

  2. The library's manifest automatically adds a request for RECEIVE_BOOT_COMPLETED to the manifest to enable scanning at startup. If you don't want this to happen, simply add this line to your app's manifest to keep it from getting merged in:

    <uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" tools:node="remove" />
    

Upvotes: 1

Related Questions