@Override protected void onAfterViews() { super.onAfterViews(); AQuery q = new AQuery(getView()); // ハートレートモニター設定 { FitnessDeviceCallbackImpl callback = new FitnessDeviceCallbackImpl(FitnessDeviceType.HEARTRATE_MONITOR, heartrateDevices); heartrateController = FitnessDeviceType.HEARTRATE_MONITOR.createController(getActivity()); heartrateController.setBleScanCallback(callback); heartrateAdapter = new BasicSpinnerAdapter(getActivity()); q.id(R.id.Setting_RoadBikeProfile_HeartrateMonitor_Selector) .adapter(heartrateAdapter) .itemSelected(callback); } // ケイデンスセンサー設定 { FitnessDeviceCallbackImpl callback = new FitnessDeviceCallbackImpl(FitnessDeviceType.SPEED_CADENCE_SENSOR, cadenceDevices); cadenceSpeedController = FitnessDeviceType.SPEED_CADENCE_SENSOR.createController(getActivity()); cadenceSpeedController.setBleScanCallback(callback); cadenceAdapter = new BasicSpinnerAdapter(getActivity()); q.id(R.id.Setting_RoadBikeProfile_SpeedAndCadence_Selector) .adapter(cadenceAdapter) .itemSelected(callback); } }
@Override public void onPause() { super.onPause(); // スキャンを終了させる heartrateController.disconnect(); cadenceSpeedController.disconnect(); }
@Override public void onResume() { super.onResume(); // 必要であればスキャンを復旧させる if (scanBleDevice) { heartrateController.connect(); cadenceSpeedController.connect(); } // デバイスを読み込む loadDeviceCache(FitnessDeviceType.HEARTRATE_MONITOR); loadDeviceCache(FitnessDeviceType.SPEED_CADENCE_SENSOR); }
@Override public void onRequestPermissionsResult( int requestCode, String[] permissions, int[] grantResults) { super.onRequestPermissionsResult(requestCode, permissions, grantResults); }