-1

I am creating an application for a challenge as an android developer that reads ibeacons with the altbeacons library.

I was able to identify the UUID, Major, Minor .. but in the test asks to do this reading with bluetooth turned off, searched and found nothing, somehow is it possible to do this?

Please help me and sorry my english.

Thanks!

I'm using didRangeBeaconsInRegion to detect

public void onBeaconServiceConnect() {

    beaconManager.removeAllMonitorNotifiers();

    beaconManager.removeAllRangeNotifiers();
    beaconManager.addRangeNotifier(new RangeNotifier() {
        @Override
        public void didRangeBeaconsInRegion(Collection<Beacon> beacons, Region region) {
            if (beacons.size() > 0) {
                Log.i(TAG, "my first beacon "
                        + beacons.iterator().next().getId1() + " "
                        + beacons.iterator().next().getId2() + " "
                        + beacons.iterator().next().getId3());

            }
        }
    });

    try {
        beaconManager.startRangingBeaconsInRegion(new Region("myRangingUniqueId", null, null, null));
    } catch (RemoteException e) {

    }
}

2 Answers2

1

Let's be clear: there is absolutely no way to detect bluetooth beacons if bluetooth is really powered off. If you think about it, the question doesn't even make sense. How could you receive a radio signal with a the radio receiver turned off?

The only caveat here is that the quick panel bluetooth icon on some Android device models and operating system versions doesn't really turn the radio off when you move the icon to the off position -- it is still available for scans (all that is needed for beacon detection), but not for Bluetooth LE connections or Bluetooth classic pairing. But not all Android devices behave this way. And for those that do, the indicator is simply telling you mistruth when it says bluetooth is off.

davidgyoung
  • 63,876
  • 14
  • 121
  • 204
  • That makes a lot of sense to me, I even noticed the difference you mentioned in two different handsets. Another question, if I need to identify a specific UUID indicator, but when it goes into didEnterRegion I only get the UUID and the minor major comes as null, would I need to do didRangeBeaconsInRegion? I set the region as follows region = new Region ("region", Identifier.parse ("UUID"), null, null); – Diego Prado Aug 13 '19 at 18:31
  • Can you please post your other question as a new question? – davidgyoung Aug 13 '19 at 23:51
-2

My example:

@Override
public void onBeaconServiceConnect() {
        beaconManager.addMonitorNotifier(new MonitorNotifier() {
        @Override
        public void didEnterRegion(Region region) {
            Log.i(TAG, " enter region");
            try {
                beaconManager.startRangingBeaconsInRegion(region);
                Log.i(TAG, "region beacon" + region.getId1() + " " + region.getId2() + " " + region.getId3());
            } catch (RemoteException e) {
                e.printStackTrace();
            }
        }

        @Override
        public void didExitRegion(Region region) {
            Log.i(TAG, "I no longer see an beacon");
            try {
                beaconManager.stopRangingBeaconsInRegion(region);
            } catch (RemoteException e) {
                e.printStackTrace();
            }
        }

        @Override
        public void didDetermineStateForRegion(int state, Region region) {
            Log.i(TAG, "I have just switched from seeing/not seeing beacons: "+ state);
        }
    });

}

when i come in with didRangeBeaconsInRegion i get major and minor