Search in sources :

Example 1 with BeaconManager

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

the class MonitoringStatusTest method allowsAccessToRegionsAfterRestore.

@TargetApi(Build.VERSION_CODES.HONEYCOMB)
@Test
public void allowsAccessToRegionsAfterRestore() throws Exception {
    Context context = ShadowApplication.getInstance().getApplicationContext();
    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();
    BeaconManager beaconManager = BeaconManager.getInstanceForApplication(context);
    Collection<Region> regions = beaconManager.getMonitoredRegions();
    assertEquals("beaconManager should return restored regions", 50, regions.size());
}
Also used : Context(android.content.Context) BeaconManager(org.altbeacon.beacon.BeaconManager) Region(org.altbeacon.beacon.Region) Test(org.junit.Test) TargetApi(android.annotation.TargetApi)

Example 2 with BeaconManager

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

the class StartupBroadcastReceiver method onReceive.

@Override
public void onReceive(Context context, Intent intent) {
    LogManager.d(TAG, "onReceive called in startup broadcast receiver");
    if (android.os.Build.VERSION.SDK_INT < 18) {
        LogManager.w(TAG, "Not starting up beacon service because we do not have API version 18 (Android 4.3).  We have: %s", android.os.Build.VERSION.SDK_INT);
        return;
    }
    BeaconManager beaconManager = BeaconManager.getInstanceForApplication(context.getApplicationContext());
    if (beaconManager.isAnyConsumerBound()) {
        if (intent.getBooleanExtra("wakeup", false)) {
            LogManager.d(TAG, "got wake up intent");
        } else {
            LogManager.d(TAG, "Already started.  Ignoring intent: %s of type: %s", intent, intent.getStringExtra("wakeup"));
        }
    }
}
Also used : BeaconManager(org.altbeacon.beacon.BeaconManager)

Aggregations

BeaconManager (org.altbeacon.beacon.BeaconManager)2 TargetApi (android.annotation.TargetApi)1 Context (android.content.Context)1 Region (org.altbeacon.beacon.Region)1 Test (org.junit.Test)1