Search in sources :

Example 21 with Region

use of org.altbeacon.beacon.Region in project android-beacon-library by AltBeacon.

the class RegionBootstrap method disable.

/**
 * Used to disable additional bootstrap callbacks after the first is received.  Unless this is called,
 * your application will be get additional calls as the supplied regions are entered or exited.
 */
public void disable() {
    if (disabled) {
        return;
    }
    disabled = true;
    try {
        for (Region region : regions) {
            beaconManager.stopMonitoringBeaconsInRegion(region);
        }
    } catch (RemoteException e) {
        LogManager.e(e, TAG, "Can't stop bootstrap regions");
    }
    beaconManager.unbind(beaconConsumer);
}
Also used : Region(org.altbeacon.beacon.Region) RemoteException(android.os.RemoteException)

Example 22 with Region

use of org.altbeacon.beacon.Region in project android-beacon-library by AltBeacon.

the class MonitoringStatusTest method savesStatusOfUpTo50RegionsTest.

@Test
public void savesStatusOfUpTo50RegionsTest() throws Exception {
    Context context = RuntimeEnvironment.application;
    MonitoringStatus monitoringStatus = new MonitoringStatus(context);
    for (int i = 0; i < 50; i++) {
        Region region = new Region("" + i, null, null, null);
        monitoringStatus.addRegion(region, null);
    }
    monitoringStatus.saveMonitoringStatusIfOn();
    MonitoringStatus monitoringStatus2 = new MonitoringStatus(context);
    assertEquals("restored regions should be same number as saved", 50, monitoringStatus2.regions().size());
}
Also used : Context(android.content.Context) Region(org.altbeacon.beacon.Region) Test(org.junit.Test)

Example 23 with Region

use of org.altbeacon.beacon.Region in project android-beacon-library by AltBeacon.

the class MonitoringStatusTest method clearsStatusOfOver50RegionsTest.

@Test
public void clearsStatusOfOver50RegionsTest() throws Exception {
    Context context = RuntimeEnvironment.application;
    MonitoringStatus monitoringStatus = new MonitoringStatus(context);
    for (int i = 0; i < 51; i++) {
        Region region = new Region("" + i, null, null, null);
        monitoringStatus.addRegion(region, null);
    }
    monitoringStatus.saveMonitoringStatusIfOn();
    MonitoringStatus monitoringStatus2 = new MonitoringStatus(context);
    assertEquals("restored regions should be none", 0, monitoringStatus2.regions().size());
}
Also used : Context(android.content.Context) Region(org.altbeacon.beacon.Region) Test(org.junit.Test)

Aggregations

Region (org.altbeacon.beacon.Region)23 Context (android.content.Context)6 Test (org.junit.Test)6 ArrayList (java.util.ArrayList)4 Beacon (org.altbeacon.beacon.Beacon)4 Bundle (android.os.Bundle)2 IOException (java.io.IOException)2 HashMap (java.util.HashMap)2 ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)2 BeaconManager (org.altbeacon.beacon.BeaconManager)2 BeaconParser (org.altbeacon.beacon.BeaconParser)2 Identifier (org.altbeacon.beacon.Identifier)2 ScanFilter (android.bluetooth.le.ScanFilter)1 ParcelUuid (android.os.ParcelUuid)1 RemoteException (android.os.RemoteException)1 MainThread (androidx.annotation.MainThread)1 WorkerThread (androidx.annotation.WorkerThread)1 FileInputStream (java.io.FileInputStream)1 FileOutputStream (java.io.FileOutputStream)1 InvalidClassException (java.io.InvalidClassException)1