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());
}
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"));
}
}
}
Aggregations