Altbeacon library not working on Android 5.0
Asked Answered
I

2

8

Yesterday I got the update for Android 5.0 on my Nexus 4, and the altbeacon library stopped detecting beacons. It appears that didEnterRegion and didRangeBeaconsInRegion are not even getting called when monitoring and ranging, respectively.

Even the Locate app from Radius Networks behaves differently now, the values from beacons, once they are detected, doesn't get updated anymore and often it appears as if the beacons went out of range.

One thing I noted differently, is that now in the logcat it appears the following line "BluetoothLeScanner﹕ could not find callback wrapper". I went ahead and looked for that class and saw that it was introduced with Android L, but I don't know if that has something to do with it.

It's important to say that before the update I had been working with both the Locate app and the Reference Application without any trouble.

I don't know if this is a generalized problem or not, but if it happened to me I'm sure it could happen to someone else, so any help it would really be appreciated.

Thanks in advance!

UPDATE:

After failing at getting the library to work I decided to try the Android L branch of the library. What I did was that I plugged in the new library into the Reference App, but didn't work as expected either.

The Monitor Activity seems to be working ok by notifying when the device has entered a new region. However, the Ranging Activity doesn't report any beacons, although didRangeBeaconsInRegion is getting called, always report zero beacons. Curiously, when the activity is paused (switching momentarily to another app) the logcat shows that now didRangeBeaconsInRegion does get called with actual beacons.

I'm kind of stuck right now because I don't know how to get any of libraries working on Android L, so again, any help would really be appreciated.

Isiah answered 18/11, 2014 at 17:4 Comment(4)
Hey, Did you get a solution for this. I upgraded my nexus to L and got similar problemHeathenism
I have a similar problem. But it was working for me on a device with Lollipop one day, and next day exactly this happens.Lamori
have you tried different devices? I have just been doing a lot of reading on BLE and saw that people using the Nexus4 have poor success with BLE scanningDeforce
Confirmed issue on Nexus 5 as well. beacon.size() is always 0, but didRangeBeaconsInRegion() is getting called.Mustee
M
1

I'm using the latest Altbeacon build on 5.0+ and have no problem with it. in fact, I never used it on kitkat so i'm not really sure i can help but here is my working code which listen to iBeacons.

implement beaconConsumer:

public class MainActivity implements BeaconConsumer

init BeaconManager

        beaconManager = BeaconManager.getInstanceForApplication(this);
        if (beaconManager != null && !beaconManager.isBound(this)) {
        beaconManager.getBeaconParsers().add(new BeaconParser().
                setBeaconLayout("m:0-3=4c000215,i:4-19,i:20-21,i:22-23,p:24-24"));
        beaconManager.bind(this);
    }

onConnect and start listner

            @Override
public void onBeaconServiceConnect() {
    beaconManager.setRangeNotifier(new RangeNotifier() {
        @Override
        public void didRangeBeaconsInRegion(Collection<Beacon> beacons, Region region) {
            if (beacons.size() > 0) {
                Beacon firstBeacon = beacons.iterator().next();

            }
        } 
     });
    beaconManager.startRangingBeaconsInRegion(new Region("com.example.app", null, null, null));
}

this code is working on 3 devices

  1. Nexus 4 5.0.1
  2. Samsung Galaxy s4 - Stock 5.0.1
  3. Samsung Galaxy s4 - CM12 5.1.1
Motel answered 14/7, 2015 at 14:32 Comment(0)
E
0

Old question, but maybe some people will try to find answer for higher systems where you have to ask for permissions. You need to ask for Manifest.permission.ACCESS_FINE_LOCATION before scanning. At least that was the problem I met. In my opinion lib should crash such cases at least and indicate the problem

Educational answered 12/11, 2017 at 10:24 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.