didRangeBeaconsInRegion doesn't work always in altBeacon library

413 views Asked by At

I use alt beacon library for my project but I have a big problem in get beacons. In first time, the method detect 1 or 2 beacons and after doesn't detect any beacons. The beacons are good launched (I have checked with LOCATE APP and all right). Also I have deactivated the wifi. I have read some solutions in stackoverflow but anything is not good for my problem.

The code for get beacons is:

    @Override
public void onBeaconServiceConnect() {

    try {
        beaconManager.startRangingBeaconsInRegion(new Region("myRangingUniqueId", null, null, null));
    } catch (RemoteException e) {
        e.printStackTrace();
    }
    beaconManager.addRangeNotifier(new RangeNotifier() {
        @Override
        public void didRangeBeaconsInRegion(Collection<Beacon> collection, Region region) {
            for (Beacon oneBeacon : collection) {
                toProcessBeacon(oneBeacon);

            }

        }

    });
}

The first time (1 or 2 beacons) the detention is good, but after is not good.

The log is the next:

01-03 16:44:53.531  D/BluetoothLeScanner: onScanResult() - ScanResult{mDevice=73:64:DC:CC:28:89, mScanRecord=ScanRecord [mAdvertiseFlags=-1, mServiceUuids=null, mManufacturerSpecificData={280=[-66, -84, -8, -49, -59, 97, 8, -28, 120, 120, 120, 120, 120, 127, 127, 127, 127, 127, 0, 1, 0, 0, -56, 0]}, mServiceData={}, mTxPowerLevel=-2147483648, mDeviceName=null], mRssi=-35, mTimestampNanos=2335797686443}
01-03 16:44:54.546  D/ScanRecord: parseFromBytes
01-03 16:44:54.551  D/ScanRecord: first manudata for manu ID**strong text**

pd : My phones are SAMSUNG GALAXY ALPHA and LG MOTO E, both 5.0.2 Android Version

Many thanks!!

1

There are 1 answers

0
JMR On BEST ANSWER

The problem was the next:

@davidyoung said me which the problem could be the Android lifecycle. He was right it. In the program was a infinite loop.

Thanks you @davidyoung.