0

I am using Android beacon library and have implemented RegionbootStrap following way:

In Application class

public void onCreate() {
    super.onCreate();

    Region region = new Region(getPackageName(), null, null, null);
    mRegionBootstrap = new RegionBootstrap(this, region);
    new BackgroundPowerSaver(this);
}

@Override
public void didEnterRegion(Region arg0) {
    mRegionBootstrap.disable();

    Intent intent = new Intent(this, MainActivity.class);
    intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    startActivity(intent);
}

In manifest

<activity
android:name=".activity.MainActivity"
android:configChanges="keyboardHidden|orientation|keyboard"
android:launchMode="singleInstance"
android:screenOrientation="portrait" >
    <intent-filter>
        <action android:name="android.intent.action.MAIN" />

        <category android:name="android.intent.category.LAUNCHER" />
    </intent-filter>
    <intent-filter>
        <action android:name="android.intent.action.VIEW" />

        <category android:name="android.intent.category.DEFAULT" />
        <category android:name="android.intent.category.BROWSABLE" />
    </intent-filter>
</activity>

When I start the application, it successfully scans iBeacons in foreground and background using RangeNotifier. I also use my own periods for scanning and delay for scanning. But I don't know how the get test the RegionbootStrap. I have tried to launch the application, then force close it, reboot device and go near iBeacon. Also tried to plug/unplug USB cable near iBeacon giving no callbacks either.

Thanks.

Niko
  • 8,093
  • 5
  • 49
  • 85

1 Answers1

0

Problem was that iBeacon was not found because I only added new BeaconParser in my Activity.

Solution was to call following in Application class to register iBeacon for RegionBootstrap:

sBeaconManager = BeaconManager.getInstanceForApplication(this);

// Add support for iBeacon
sBeaconManager
        .getBeaconParsers()
        .add(new BeaconParser()
        .setBeaconLayout("m:2-3=0215,i:4-19,i:20-21,i:22-23,p:24-24"));
Niko
  • 8,093
  • 5
  • 49
  • 85