当前位置: 首页>>代码示例>>Java>>正文


Java BackgroundPowerSaver类代码示例

本文整理汇总了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();
}
 
开发者ID:VNGIoTLab,项目名称:vbluno_android_ibeacon,代码行数:24,代码来源:BeaconReferenceApplication.java

示例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();
}
 
开发者ID:JonathanVidmar,项目名称:BLEPublicTransport,代码行数:30,代码来源:BLEPublicTransport.java

示例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));
}
 
开发者ID:MycroftAI,项目名称:Mycroft-Android,代码行数:15,代码来源:MycroftApplication.java

示例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);
}
 
开发者ID:upnext,项目名称:BeaconControl_Android_SDK,代码行数:9,代码来源:BeaconControl.java

示例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);

  }
 
开发者ID:lulibrary,项目名称:Background-Beacon-Monitoring,代码行数:28,代码来源:BackgroundBeaconService.java

示例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);
}
 
开发者ID:carlgonz,项目名称:bus-beacon,代码行数:14,代码来源:BeaconReferenceApplication.java

示例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());
}
 
开发者ID:Orchextra,项目名称:orchextra-android-sdk,代码行数:4,代码来源:BeaconsModule.java

示例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);
    }
}
 
开发者ID:vitas,项目名称:beaconloc,代码行数:52,代码来源:BeaconLocatorApp.java

示例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));
    }
 
开发者ID:swandroid,项目名称:swan-sense-studio,代码行数:47,代码来源:BeaconInitializer.java


注:本文中的org.altbeacon.beacon.powersave.BackgroundPowerSaver类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。