Altbeacon Application Crashes On Android Tab
I have been trying to use the AltBeacon Monitoring Example Code to monitor my Kontakt.io beacon as described http://altbeacon.github.io/android-beacon-library/samples.html here. I
Solution 1:
The example inits beaconManager this way:
privateBeaconManagerbeaconManager= beaconManager.getInstanceForApplication(this);
You should do it inside onCreate() method of your Activity.
publicclassMainActivityextendsActivityimplementsBeaconConsumer{
protectedstaticfinalStringTAG="RangingActivity";
private BeaconManager;
@OverrideprotectedvoidonCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main_layout);
beaconManager = BeaconManager.getInstanceForApplication(this);
beaconManager.getBeaconParsers().add(newBeaconParser().setBeaconLayout("m:2-3=0216,i:4-19,i:20-21,i:22-23,p:24-24"));
// set the duration of the scan to be 1.1 seconds
beaconManager.setBackgroundScanPeriod(1100l);
// set the time between each scan to be 1 hour (3600 seconds)
beaconManager.setBackgroundBetweenScanPeriod(1000);
beaconManager.bind(this);
}
Post a Comment for "Altbeacon Application Crashes On Android Tab"