Skip to content Skip to sidebar Skip to footer

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);

    }

Solution 2:

I would need to see the code that calls BeaconManager.getInstanceForApplication(context) to be sure, but the stack trace suggests this code is receiving a null context. The passed context must be a non-null, valid instance of an Activity, Application or Service.

Post a Comment for "Altbeacon Application Crashes On Android Tab"