本文整理汇总了Java中org.altbeacon.beacon.BeaconManager类的典型用法代码示例。如果您正苦于以下问题:Java BeaconManager类的具体用法?Java BeaconManager怎么用?Java BeaconManager使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
BeaconManager类属于org.altbeacon.beacon包,在下文中一共展示了BeaconManager类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onCreate
import org.altbeacon.beacon.BeaconManager; //导入依赖的package包/类
@Override
public void onCreate() {
super.onCreate();
if (mqttBroadcaster == null) {
mqttBroadcaster = new MqttBroadcaster(this);
} // TODO: Should I set the context again?
final BeaconManager beaconManager = setUpBeaconManager();
SharedPreferences defaultSharedPreferences = PreferenceManager.getDefaultSharedPreferences(this);
setUpSettingsChangedListener(beaconManager, defaultSharedPreferences);
setUpScanningSettings(beaconManager, defaultSharedPreferences);
startSearchForBeacons();
}
示例2: onCreate
import org.altbeacon.beacon.BeaconManager; //导入依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
beaconList = (ListView) findViewById(R.id.beacon_list);
beaconManager = BeaconManager.getInstanceForApplication(this);
// Detect the main identifier (UID) frame:
beaconManager.getBeaconParsers().add(new BeaconParser().
setBeaconLayout(BeaconParser.EDDYSTONE_UID_LAYOUT));
// Detect the telemetry (TLM) frame:
beaconManager.getBeaconParsers().add(new BeaconParser().
setBeaconLayout(BeaconParser.EDDYSTONE_TLM_LAYOUT));
// Detect the URL frame:
beaconManager.getBeaconParsers().add(new BeaconParser().
setBeaconLayout(BeaconParser.EDDYSTONE_URL_LAYOUT));
beaconManager.bind(this);
}
示例3: initiateBeaconService
import org.altbeacon.beacon.BeaconManager; //导入依赖的package包/类
private void initiateBeaconService() {
beaconManager = BeaconManager.getInstanceForApplication(this.getApplicationContext());
// Detect the main identifier (UID) frame:
beaconManager.getBeaconParsers().add(new BeaconParser().
setBeaconLayout(BeaconParser.EDDYSTONE_UID_LAYOUT));
// Detect the telemetry (TLM) frame:
beaconManager.getBeaconParsers().add(new BeaconParser().
setBeaconLayout(BeaconParser.EDDYSTONE_TLM_LAYOUT));
// Detect the URL frame:
beaconManager.getBeaconParsers().add(new BeaconParser().
setBeaconLayout(BeaconParser.EDDYSTONE_URL_LAYOUT));
//beaconManager.setDebug(true);
beaconManager.setBackgroundScanPeriod(1100l);
beaconManager.setBackgroundBetweenScanPeriod(30000l);
beaconManager.bind(this);
}
示例4: onCreate
import org.altbeacon.beacon.BeaconManager; //导入依赖的package包/类
public void onCreate() {
super.onCreate();
BeaconManager beaconManager = org.altbeacon.beacon.BeaconManager.getInstanceForApplication(this);
// Add parser for iBeacons;
beaconManager.getBeaconParsers().add(new BeaconParser().
setBeaconLayout("m:2-3=0215,i:4-19,i:20-21,i:22-23,p:24-24"));
Log.d(TAG, "setting up background monitoring for beacons and power saving");
// wake up the app when a beacon is seen
Region region = new Region("backgroundRegion",
null, null, null);
regionBootstrap = new RegionBootstrap(this, region);
// simply constructing this class and holding a reference to it in your custom Application
// class will automatically cause the BeaconLibrary to save battery whenever the application
// is not visible. This reduces bluetooth power usage by about 60%
backgroundPowerSaver = new BackgroundPowerSaver(this);
// If you wish to test beacon detection in the Android Emulator, you can use code like this:
// BeaconManager.setBeaconSimulator(new TimedBeaconSimulator() );
// ((TimedBeaconSimulator) BeaconManager.getBeaconSimulator()).createTimedSimulatedBeacons();
}
示例5: onCreate
import org.altbeacon.beacon.BeaconManager; //导入依赖的package包/类
@Override
public void onCreate() {
Toast.makeText(context, "Service created!", Toast.LENGTH_LONG).show();
beaconManager = BeaconManager.getInstanceForApplication(this);
beaconManager.getBeaconParsers().add(new BeaconParser().setBeaconLayout("m:0-3=4c000215,i:4-19,i:20-21,i:22-23,p:24-24"));
beaconManager.setBackgroundScanPeriod(1500l);
beaconManager.setBackgroundBetweenScanPeriod(30000l);
beaconManager.setForegroundScanPeriod(2000l);
beaconManager.setForegroundBetweenScanPeriod(4000l);
//Start Monitoring and Ranging
beaconManager.bind(this);
// handler = new Handler();
// runnable = new Runnable() {
// public void run() {
// Toast.makeText(context, "Service is still running", Toast.LENGTH_LONG).show();
// handler.postDelayed(runnable, 5000);
// }
// };
//
// handler.postDelayed(runnable, 5000);
}
示例6: Scanner
import org.altbeacon.beacon.BeaconManager; //导入依赖的package包/类
public Scanner(
@NonNull Context context,
@NonNull OnScanBeaconsListener callback,
@NonNull BeaconManager beaconManager) {
_logger = new Logger(TAG);
_logger.Debug("Scanner created...");
_preferences = PreferenceManager.getDefaultSharedPreferences(context);
try {
_onScanBeaconsCallback = callback;
} catch (ClassCastException notImplementedException) {
throw new ClassCastException("Class must implement OnScanBeaconsListener");
}
_context = context;
_beaconManager = beaconManager;
setUpBeaconManager();
setBeaconLayouts();
}
示例7: BleManager
import org.altbeacon.beacon.BeaconManager; //导入依赖的package包/类
@Inject
public BleManager(@ForApplication Context context, PreferenceManager prefsManager) {
this.context = context;
// the app manifest requires support for BLE, no need to check explicitly
bluetoothManager = (BluetoothManager) context.getSystemService(Context.BLUETOOTH_SERVICE);
bluetoothAdapter = bluetoothManager.getAdapter();
preferenceManager = prefsManager;
gattManager = new GattManager(prefsManager, this);
// Beaconing
beaconManager = org.altbeacon.beacon.BeaconManager.getInstanceForApplication(context);
beaconManager.getBeaconParsers().clear();
beaconManager.getBeaconParsers().add(new BeaconParser().
setBeaconLayout("m:2-3=0215,i:4-19,i:20-21,i:22-23,p:24-24,d:25-25"));
Timber.d("setting up background monitoring for beacons and power saving");
Identifier id1 = Identifier.parse(ThunderBoardDevice.THUNDER_BOARD_REACT_UUID_STRING);
Region region = new Region("backgroundRegion", id1, null, null);
regionBootstrap = new ThunderBoardBootstrap(context, this, region);
backgroundPowerSaver = new ThunderBoardPowerSaver(context, preferenceManager);
beaconManager.setBackgroundBetweenScanPeriod(ThunderBoardPowerSaver.DELAY_BETWEEN_SCANS_INACTIVE);
}
示例8: ThunderBoardPowerSaver
import org.altbeacon.beacon.BeaconManager; //导入依赖的package包/类
public ThunderBoardPowerSaver(Context context, PreferenceManager preferenceManager) {
if (android.os.Build.VERSION.SDK_INT < 18) {
Timber.d("BackgroundPowerSaver requires API 18 or higher.");
return;
}
if (context instanceof Application) {
((Application) context).registerActivityLifecycleCallbacks(this);
} else {
Timber.e("Context is not an application instance, so we cannot use the BackgroundPowerSaver");
}
this.preferenceManager = preferenceManager;
this.beaconManager = BeaconManager.getInstanceForApplication(context);
}
示例9: onCreateView
import org.altbeacon.beacon.BeaconManager; //导入依赖的package包/类
@Nullable
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
View beaconListView = inflater.inflate(R.layout.fragment_main, container, false);
ButterKnife.bind(this, beaconListView);
// Setting toolbar.
setToolbar();
// Setting linear layout manager as layout manager for the beacon recycler view.
beaconRecycler.setLayoutManager(new LinearLayoutManager(getActivity()));
// Getting instance of beacon manager.
beaconManager = BeaconManager.getInstanceForApplication(getActivity());
// Initializing scan service.
initBeaconScanService();
// Initializing transmit service.
if (Build.VERSION.SDK_INT > Build.VERSION_CODES.LOLLIPOP) initBeaconTransmitService();
// Disables dragging on switch button
disableSwitchDrag();
// Updates user interface so that all the right views are displayed.
updateUI();
return beaconListView;
}
示例10: onStartCommand
import org.altbeacon.beacon.BeaconManager; //导入依赖的package包/类
@Override
public int onStartCommand(Intent intent, int flags, int startId) {
Log.i(TAG, "onStartCommand method called");
beaconManager = BeaconManager.getInstanceForApplication(this);
beaconManager.getBeaconParsers().add(new BeaconParser().
setBeaconLayout("m:2-3=0215,i:4-19,i:20-21,i:22-23,p:24-24,d:25-25"));
beaconManager.bind(this);
RangedBeacon.setSampleExpirationMilliseconds(10000);
//ArmaRssiFilter.setDEFAULT_ARMA_SPEED(1);
myDBHandler = new DBHandler(this, null, null, 1);
// restart the service if the service is closed somehow
return Service.START_STICKY;
}
示例11: stopRangingAllRegions
import org.altbeacon.beacon.BeaconManager; //导入依赖的package包/类
private void stopRangingAllRegions() {
Iterator<Region> iterator = regions.iterator();
while (iterator.hasNext()){
try {
Region region = iterator.next();
beaconManager.stopRangingBeaconsInRegion(region);
removeScheduledEndOfRanging(region);
iterator.remove();
} catch (RemoteException e) {
e.printStackTrace();
}
}
updateBackgroundScanTimes(BeaconManager.DEFAULT_BACKGROUND_SCAN_PERIOD,
OrchextraManager.getBackgroundPeriodBetweenScan());
ranging = false;
orchextraLogger.log("Ranging stop");
}
示例12: startBeaconService
import org.altbeacon.beacon.BeaconManager; //导入依赖的package包/类
/**
* Start the XamoomBeaconService with a beacon majorId.
* This will automatically start (background-)monitoring for xamoom beacons
* with the used majorId.
*
* @param majorId MajorId you get from your xamoom system.
*/
public void startBeaconService(@NonNull String majorId) {
Log.i(TAG, "startBeaconService");
if (majorId.equalsIgnoreCase("")) {
throw new IllegalArgumentException("MajorId should not be a number.");
}
mRegion = new Region("test", Identifier.parse("de2b94ae-ed98-11e4-3432-78616d6f6f6d"),
Identifier.parse(majorId), null);
mRegionBootstrap = new RegionBootstrap(this, mRegion);
mBeaconManager = BeaconManager.getInstanceForApplication(mContext);
mBeaconManager.getBeaconParsers().add(new BeaconParser().
setBeaconLayout("m:2-3=0215,i:4-19,i:20-21,i:22-23,p:24-24"));
mBeaconManager.setRangeNotifier(this);
mBeaconManager.bind(this);
}
示例13: onCreate
import org.altbeacon.beacon.BeaconManager; //导入依赖的package包/类
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
mBeacons = new ArrayList<>();
mAdapter = new BeaconListAdapter(getActivity(), mBeacons);
setListAdapter(mAdapter);
// Beacon: simulator
if (BeaconSimulator.USE_SIMULATED_BEACONS) BeaconManager.setBeaconSimulator(new BeaconSimulator());
// Beacon: set initial parameters and start scanning, if ble is present
mBeaconManager = BeaconManager.getInstanceForApplication(getActivity());
mBeaconManager.getBeaconParsers().add(new BeaconParser().setBeaconLayout(BeaconLayout.IBEACON.layout()));
mBeaconManager.bind(this);
}
示例14: onCreateView
import org.altbeacon.beacon.BeaconManager; //导入依赖的package包/类
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
View v = inflater.inflate(R.layout.fragment_beacon, container, false);
mBeaconUUIDTextView = (TextView) v.findViewById(R.id.beaconUUIDTextView);
mBeaconMajorTextView = (TextView) v.findViewById(R.id.beaconMajorTextView);
mbeaconMinorTextView = (TextView) v.findViewById(R.id.beaconMinorTextView);
mBeaconDistanceTextView = (TextView) v.findViewById(R.id.beaconDistanceTextView);
loadBeacon();
// If beacon simulator is set, create beacons
if (BeaconManager.getBeaconSimulator() != null)
((BeaconSimulator) BeaconManager.getBeaconSimulator()).createBasicSimulatedBeacons();
return v;
}
示例15: onCycleEnd
import org.altbeacon.beacon.BeaconManager; //导入依赖的package包/类
public void onCycleEnd() {
mMonitoringStatus.updateNewlyOutside();
processRangeData();
if (BeaconManager.getBeaconSimulator() != null) {
// if simulatedScanData is provided, it will be seen every scan cycle. *in addition* to anything actually seen in the air
// it will not be used if we are not in debug mode
if (BeaconManager.getBeaconSimulator().getBeacons() != null) {
if (0 != (mService.getApplicationContext().getApplicationInfo().flags &= ApplicationInfo.FLAG_DEBUGGABLE)) {
for (Beacon beacon : BeaconManager.getBeaconSimulator().getBeacons()) {
processBeaconFromScan(beacon);
}
} else {
LogManager.w(TAG, "Beacon simulations provided, but ignored because we are not running in debug mode. Please remove beacon simulations for production.");
}
} else {
LogManager.w(TAG, "getBeacons is returning null. No simulated beacons to report.");
}
}
}