本文整理汇总了Java中org.altbeacon.beacon.powersave.BackgroundPowerSaver类的典型用法代码示例。如果您正苦于以下问题:Java BackgroundPowerSaver类的具体用法?Java BackgroundPowerSaver怎么用?Java BackgroundPowerSaver使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
BackgroundPowerSaver类属于org.altbeacon.beacon.powersave包,在下文中一共展示了BackgroundPowerSaver类的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onCreate
import org.altbeacon.beacon.powersave.BackgroundPowerSaver; //导入依赖的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();
}
示例2: onCreate
import org.altbeacon.beacon.powersave.BackgroundPowerSaver; //导入依赖的package包/类
public void onCreate() {
super.onCreate();
settings = getSharedPreferences(SettingConstants.SETTINGS_PREFERENCES, 0);
beaconHelper = new BeaconHelper(settings.getBoolean(SettingConstants.SELF_CORRECTING_BEACON, true));
beaconHelper.updateProcessNoise(settings.getInt(SettingConstants.KALMAN_SEEK_VALUE, 83));
bluetoothClient = new BluetoothClient(this);
walkDetection = new WalkDetection(this);
updateWalkDetectionListener(settings.getBoolean(SettingConstants.WALK_DETECTION, false));
beaconManager = BeaconManager.getInstanceForApplication(this);
beaconManager.getBeaconParsers().clear();
beaconManager.getBeaconParsers().add(new BeaconParser().setBeaconLayout(EDDYSTONE_LAYOUT));
try {
beaconManager.setForegroundScanPeriod(700l);
beaconManager.setForegroundBetweenScanPeriod(0l);
beaconManager.setBackgroundScanPeriod(700l);
beaconManager.setBackgroundBetweenScanPeriod(0l);
beaconManager.updateScanPeriods();
} catch (RemoteException e) {
e.printStackTrace();
}
regionBootstrap = new RegionBootstrap(this, REGIONS);
BackgroundPowerSaver backgroundPowerSaver = new BackgroundPowerSaver(this);
notificationHandler = new NotificationHandler(this);
beaconCommunicator = new BeaconCommunicator();
}
示例3: onCreate
import org.altbeacon.beacon.powersave.BackgroundPowerSaver; //导入依赖的package包/类
public void onCreate() {
super.onCreate();
MycroftApplication.context = getApplicationContext();
beaconManager = org.altbeacon.beacon.BeaconManager.getInstanceForApplication(this);
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);
backgroundPowerSaver = new BackgroundPowerSaver(this);
setBeaconScanSettings(getString(R.string.beacon_layout));
}
示例4: BeaconControl
import org.altbeacon.beacon.powersave.BackgroundPowerSaver; //导入依赖的package包/类
private BeaconControl(Context context, Config config, BeaconPreferences preferences, BeaconControlManager beaconControlManager, TokenCredentials tokenCredentials) {
this.context = context;
preferences.setOAuthCredentials(tokenCredentials);
beaconServiceHelper = BeaconServiceHelper.getInstance(context, config, beaconControlManager);
backgroundPowerSaver = new BackgroundPowerSaver(context);
}
示例5: onCreate
import org.altbeacon.beacon.powersave.BackgroundPowerSaver; //导入依赖的package包/类
public void onCreate() {
Log.d("uk.ac.lancaster.library.backgroundbeacons", "BACKGROUND: Creating BackgroundBeaconService");
super.onCreate();
this.settings = new SharedPreferencesUtility(this.getApplicationContext());
if (this.settings.exist()) {
Log.d("uk.ac.lancaster.library.backgroundbeacons", "API PARTICIPANT TOKEN: " + this.settings.getApiParticipantToken());
Log.d("uk.ac.lancaster.library.backgroundbeacons", "API PARTICIPANT EMAIL: " + this.settings.getApiParticipantEmail());
Log.d("uk.ac.lancaster.library.backgroundbeacons", "DEVICE ID: " + this.settings.getDeviceId());
Log.d("uk.ac.lancaster.library.backgroundbeacons", "API URL: " + this.settings.getApiUrl());
Log.d("uk.ac.lancaster.library.backgroundbeacons", "API VERSION: " + this.settings.getApiVersion());
Log.d("ul.ac.lancaster.library.backgroundbeacons", "SEND MOVEMENT DATA: " + this.settings.getSendMovementData());
}
iBeaconManager = BeaconManager.getInstanceForApplication(this);
iBeaconManager.getBeaconParsers().add(new BeaconParser().setBeaconLayout("m:2-3=0215,i:4-19,i:20-21,i:22-23,p:24-24"));
backgroundPowerSaver = new BackgroundPowerSaver(this);
iBeaconManager.setDebug(true);
monitoringRegions = new HashMap<String, Region>();
rangingRegions = new HashMap<String, Region>();
monitoringConsumer = new MonitoringConsumer(this);
}
示例6: onCreate
import org.altbeacon.beacon.powersave.BackgroundPowerSaver; //导入依赖的package包/类
public void onCreate() {
super.onCreate();
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);
BeaconManager.debug = true;
// 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);
}
示例7: onCreate
import org.altbeacon.beacon.powersave.BackgroundPowerSaver; //导入依赖的package包/类
@Override
public void onCreate() {
super.onCreate();
settings = PreferenceManager.getDefaultSharedPreferences(this);
settings.registerOnSharedPreferenceChangeListener(mListener);
notificationId = 1512;
titles = new String[]{ getString(R.string.alert_notification_title0),
getString(R.string.alert_notification_title1),
getString(R.string.alert_notification_title2),
getString(R.string.alert_notification_title3),
getString(R.string.alert_notification_title4),
getString(R.string.alert_notification_title5),
getString(R.string.alert_notification_title6),
getString(R.string.alert_notification_title7)
};
if(settings.getBoolean("pref_bgscan", false))
startFG();
Foreground.init(getApplication());
Foreground.get().addListener(listener);
bps = new BackgroundPowerSaver(this);
ruuvitagArrayList = new ArrayList<>();
handler = new DBHandler(getApplicationContext());
db = handler.getWritableDatabase();
/*
beaconManager = BeaconManager.getInstanceForApplication(this);
// Detect the URL frame:
beaconManager.getBeaconParsers().add(new BeaconParser()
.setBeaconLayout(BeaconParser.EDDYSTONE_URL_LAYOUT));
beaconManager.getBeaconParsers().add(new BeaconParser().setBeaconLayout(BeaconParser.))
beaconManager.bind(this);*/
backendUrl = settings.getString("pref_backend", null);
plotSource = PlotSource.getInstance();
scanTimerHandler = new Handler();
final BluetoothManager bluetoothManager = (BluetoothManager) getSystemService(Context.BLUETOOTH_SERVICE);
bluetoothAdapter = bluetoothManager.getAdapter();
scheduler = Executors.newSingleThreadScheduledExecutor();
int scanInterval = Integer.parseInt(settings.getString("pref_scaninterval", "5")) * 1000;
scheduler.scheduleAtFixedRate(new Runnable()
{
@Override
public void run()
{
if(!scheduler.isShutdown())
startScan();
}
}, 0, scanInterval-MAX_SCAN_TIME_MS+1, TimeUnit.MILLISECONDS);
timer = new Timer();
TimerTask alertManager = new ScannerService.alertManager();
timer.scheduleAtFixedRate(alertManager, 2500, 2500);
}
开发者ID:CentriaUniversityOfAppliedSciences,项目名称:Android_RuuvitagScannner,代码行数:67,代码来源:ScannerService.java
示例8: BackgroundPowerSaver
import org.altbeacon.beacon.powersave.BackgroundPowerSaver; //导入依赖的package包/类
@Provides @Singleton BackgroundPowerSaver BackgroundPowerSaver(ContextProvider contextProvider){
return new BackgroundPowerSaver(contextProvider.getApplicationContext());
}
示例9: initBeaconManager
import org.altbeacon.beacon.powersave.BackgroundPowerSaver; //导入依赖的package包/类
private void initBeaconManager() {
mBeaconManager.setBackgroundMode(PreferencesUtil.isBackgroundScan(this));
if (PreferencesUtil.isEddystoneLayoutUID(this)) {
mBeaconManager.getBeaconParsers().add(new BeaconParser().setBeaconLayout(BeaconParser.EDDYSTONE_UID_LAYOUT));
}
if (PreferencesUtil.isEddystoneLayoutURL(this)) {
mBeaconManager.getBeaconParsers().add(new BeaconParser().setBeaconLayout(BeaconParser.EDDYSTONE_URL_LAYOUT));
}
mBeaconManager.getBeaconParsers().add(new BeaconParser().setBeaconLayout(BeaconParser.ALTBEACON_LAYOUT));
//konkakt?
mBeaconManager.getBeaconParsers().add(new BeaconParser().setBeaconLayout("m:2-3=0215,i:4-19,i:20-21,i:22-23,p:24-24,d:25-25"));
mBeaconManager.getBeaconParsers().add(new BeaconParser().setBeaconLayout("m:2-3=0215,i:4-19,i:20-21,i:22-23,p:24-24"));
mBeaconManager.getBeaconParsers().add(new BeaconParser().setBeaconLayout("m:0-3=4c000215,i:4-19,i:20-21,i:22-23,p:24-24"));
mBeaconManager.setBackgroundBetweenScanPeriod(PreferencesUtil.getBackgroundScanInterval(this));
mBeaconManager.setBackgroundScanPeriod(10000L); // default is 10000L
mBeaconManager.setForegroundBetweenScanPeriod(0L); // default is 0L
mBeaconManager.setForegroundScanPeriod(1100L); // Default is 1100L
//mBeaconManager.setMaxTrackingAge(10000);
//mBeaconManager.setRegionExitPeriod(12000L);
/*
RangedBeacon.setMaxTrackingAge() only controls the period of time ranged beacons will continue to be
returned after the scanning service stops detecting them.
It has no affect on when monitored regions trigger exits. It is set to 5 seconds by default.
Monitored regions are exited whenever a scan period finishes and the BeaconManager.setRegionExitPeriod()
has passed since the last detection.
By default, this is 10 seconds, but you can customize it.
Using the defaults, the library will stop sending ranging updates five seconds after a beacon was last seen,
and then send a region exit 10 seconds after it was last seen.
You are welcome to change these two settings to meet your needs, but the BeaconManager.setRegionExitPeriod()
should generally be the same or longer than the RangedBeacon.setMaxTrackingAge().
*/
mBackgroundPowerSaver = new BackgroundPowerSaver(this);
mBeaconManager.addRangeNotifier(this);
try {
if (mBeaconManager.isAnyConsumerBound()) {
mBeaconManager.updateScanPeriods();
}
} catch (RemoteException e) {
Log.e(Constants.TAG, "update scan periods error", e);
}
}
示例10: onCreate
import org.altbeacon.beacon.powersave.BackgroundPowerSaver; //导入依赖的package包/类
public void onCreate() {
//super.onCreate();
BeaconManager beaconManager = org.altbeacon.beacon.BeaconManager.getInstanceForApplication(this.getApplicationContext());
// By default the AndroidBeaconLibrary will only find AltBeacons. If you wish to make it
// find a different type of beacon, you must specify the byte layout for that beacon's
// advertisement with a line like below. The example shows how to find a beacon with the
// same byte layout as AltBeacon but with a beaconTypeCode of 0xaabb. To find the proper
// layout expression for other beacon types, do a web search for "setBeaconLayout"
// including the quotes.
//
beaconManager.getBeaconParsers().clear();
// // Alt beacon
beaconManager.getBeaconParsers().add(new BeaconParser().
setBeaconLayout(BeaconParser.ALTBEACON_LAYOUT));
// 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));
// Apple iBeacon
beaconManager.getBeaconParsers().add(new BeaconParser()
.setBeaconLayout("m:2-3=0215,i:4-19,i:20-21,i:22-23,p:24-24"));
// Estimote Nearable
beaconManager.getBeaconParsers().add(new BeaconParser()
.setBeaconLayout("m:1-2=0101,i:3-10,d:11-11,d:12-12,d:13-14,d:15-15,d:16-16,d:17-17,d:18-18,d:19-19,d:20-20, p:21-21"));
// 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.getApplicationContext());
//beaconManager.setDebug(true);
context.startService(new Intent(context, BeaconSingleton.class));
}