List of usage examples for android.bluetooth BluetoothAdapter ACTION_REQUEST_ENABLE
String ACTION_REQUEST_ENABLE
To view the source code for android.bluetooth BluetoothAdapter ACTION_REQUEST_ENABLE.
Click Source Link
From source file:it.prof.iotsemplicedemo.DeviceScanActivity.java
@Override protected void onResume() { super.onResume(); if (!mBluetoothAdapter.isEnabled()) { if (!mBluetoothAdapter.isEnabled()) { Intent enableBtIntent = new Intent(BluetoothAdapter.ACTION_REQUEST_ENABLE); startActivityForResult(enableBtIntent, REQUEST_ENABLE_BT); }//from ww w. ja v a 2 s. c om } bDevices = new ArrayList<BluetoothDevice>(); mLeDeviceListAdapter = new MyAdapter(bDevices, R.layout.row, this); mRecyclerView.setAdapter(mLeDeviceListAdapter); scanLeDevice(true); registerReceiver(mGattUpdateReceiver, makeGattUpdateIntentFilter()); }
From source file:com.nordicsemi.nrfUARTspoon.MainActivity.java
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main);// ww w . jav a2s. c o m mBtAdapter = BluetoothAdapter.getDefaultAdapter(); if (mBtAdapter == null) { Toast.makeText(this, "Bluetooth is not available", Toast.LENGTH_LONG).show(); finish(); return; } messageListView = (ListView) findViewById(R.id.listMessage); listAdapter = new ArrayAdapter<String>(this, R.layout.message_detail); messageListView.setAdapter(listAdapter); messageListView.setDivider(null); btnConnectDisconnect = (Button) findViewById(R.id.btn_select); btnSend = (Button) findViewById(R.id.sendButton); btnStartNewFile = (Button) findViewById(R.id.btn_start_new_file); edtMessage = (EditText) findViewById(R.id.sendText); fileMessage = (TextView) findViewById(R.id.fileStatusText); formatter = new SimpleDateFormat("yyyy_MM_dd_HH_mm_ss_SSS"); buttonGo = (Button) findViewById(R.id.btnGO); service_init(); getWindow().addFlags(WindowManager.LayoutParams.FLAG_DISMISS_KEYGUARD); // state of spoon buttons stateButtons = new Button[6]; stateButtons[0] = (Button) this.findViewById(R.id.state0_button); stateButtons[1] = (Button) this.findViewById(R.id.state1_button); stateButtons[2] = (Button) this.findViewById(R.id.state2_button); stateButtons[3] = (Button) this.findViewById(R.id.state3_button); stateButtons[4] = (Button) this.findViewById(R.id.state4_button); stateButtons[5] = (Button) this.findViewById(R.id.state5_button); stateButtons[5].setEnabled(false); buttonState = 5; final CheckBox expert = (CheckBox) findViewById(R.id.ckBoxExpertMode); final ListView listViewData = (ListView) findViewById(R.id.listMessage); buttonGo.setVisibility(View.INVISIBLE); listViewData.setVisibility(ListView.INVISIBLE); //Expert Mode Option findViewById(R.id.ckBoxExpertMode).setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { if (expert.isChecked()) { listViewData.setVisibility(ListView.VISIBLE); } else { listViewData.setVisibility(ListView.INVISIBLE); } } }); // Handler Disconnect & Connect button btnConnectDisconnect.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { //initialize stable sample buttonGo.setVisibility(View.INVISIBLE); MainActivity.stable_counter = 0; if (!mBtAdapter.isEnabled()) { Log.i(TAG, "onClick - BT not enabled yet"); Intent enableIntent = new Intent(BluetoothAdapter.ACTION_REQUEST_ENABLE); startActivityForResult(enableIntent, REQUEST_ENABLE_BT); } else { if (btnConnectDisconnect.getText().equals("Connect")) { //Connect button pressed, open DeviceListActivity class, with popup windows that scan for devices Intent newIntent = new Intent(MainActivity.this, DeviceListActivity.class); startActivityForResult(newIntent, REQUEST_SELECT_DEVICE); } else { //Disconnect button pressed if (mDevice != null) { mService.disconnect(); } } } } }); // Handler Send button btnSend.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { EditText editText = (EditText) findViewById(R.id.sendText); String message = editText.getText().toString(); byte[] value; try { //send data to service value = message.getBytes("UTF-8"); mService.writeRXCharacteristic(value); //Update the log with time stamp String currentDateTimeString = DateFormat.getTimeInstance().format(new Date()); listAdapter.add("[" + currentDateTimeString + "] TX: " + message); messageListView.smoothScrollToPosition(listAdapter.getCount() - 1); edtMessage.setText(""); } catch (UnsupportedEncodingException e) { // TODO Auto-generated catch block e.printStackTrace(); } } }); // Handler File button btnStartNewFile.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { // Close an open file if (isFileOpen) { btnStartNewFile.setText("Start new file"); fileMessage.setText("File closed"); try { Log.i(TAG, "Closing old file"); isFileOpen = false; theWriter.flush(); theWriter.close(); theWriter = null; } catch (IOException ioe) { Log.e(TAG, "Could not close previous file"); } } else { // Open a new file btnStartNewFile.setText("End file"); String currentDateTimeStringFile = formatter.format(new Date()); currentDateTimeStringFile += ".txt"; File path = Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DOCUMENTS); path.mkdirs(); File theFile = new File(path, currentDateTimeStringFile); try { theWriter = new BufferedWriter(new FileWriter(theFile)); } catch (IOException ioe) { Log.e(TAG, "Buffered writer not created at" + theFile.getPath()); return; } fileMessage.setText("Writing to " + theFile.getPath()); isFileOpen = true; fileTime = 0; } } }); // Set initial UI state }
From source file:de.sauernetworks.stm32_bluetooth_flashloader.BluetoothUpdaterFragment.java
@Override public void onStart() { super.onStart(); // If BT is not on, request that it be enabled. // setupUI() will then be called during onActivityResult if (!mBluetoothAdapter.isEnabled()) { Intent enableIntent = new Intent(BluetoothAdapter.ACTION_REQUEST_ENABLE); startActivityForResult(enableIntent, REQUEST_ENABLE_BT); // Otherwise, setup the chat session } else if (mBluetoothService == null) { setupUI();//from ww w. j a v a 2s . c o m } }
From source file:com.nordicsemi.ImageTransferDemo.MainActivity.java
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main);/*from ww w .ja va 2 s .c o m*/ mBtAdapter = BluetoothAdapter.getDefaultAdapter(); if (mBtAdapter == null) { Toast.makeText(this, "Bluetooth is not available", Toast.LENGTH_LONG).show(); finish(); return; } btnConnectDisconnect = (Button) findViewById(R.id.btn_select); mTextViewLog = (TextView) findViewById(R.id.textViewLog); mTextViewFileLabel = (TextView) findViewById(R.id.textViewFileLabel); mTextViewPictureStatus = (TextView) findViewById(R.id.textViewImageStatus); mTextViewPictureFpsStatus = (TextView) findViewById(R.id.textViewImageFpsStatus); mTextViewConInt = (TextView) findViewById(R.id.textViewCI); mTextViewMtu = (TextView) findViewById(R.id.textViewMTU); mProgressBarFileStatus = (ProgressBar) findViewById(R.id.progressBarFile); mBtnTakePicture = (Button) findViewById(R.id.buttonTakePicture); mBtnStartStream = (Button) findViewById(R.id.buttonStartStream); mMainImage = (ImageView) findViewById(R.id.imageTransfered); mSpinnerResolution = (Spinner) findViewById(R.id.spinnerResolution); mSpinnerResolution.setSelection(1); mSpinnerPhy = (Spinner) findViewById(R.id.spinnerPhy); mConnectionProgDialog = new ProgressDialog(this); mConnectionProgDialog.setTitle("Connecting..."); mConnectionProgDialog.setCancelable(false); service_init(); for (int i = 0; i < 6; i++) mUartData[i] = 0; // Handler Disconnect & Connect button btnConnectDisconnect.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { if (!mBtAdapter.isEnabled()) { Log.i(TAG, "onClick - BT not enabled yet"); Intent enableIntent = new Intent(BluetoothAdapter.ACTION_REQUEST_ENABLE); startActivityForResult(enableIntent, REQUEST_ENABLE_BT); } else { if (btnConnectDisconnect.getText().equals("Connect")) { //Connect button pressed, open DeviceListActivity class, with popup windows that scan for devices Intent newIntent = new Intent(MainActivity.this, DeviceListActivity.class); startActivityForResult(newIntent, REQUEST_SELECT_DEVICE); } else { //Disconnect button pressed if (mDevice != null) { mService.disconnect(); } } } } }); mBtnTakePicture.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { if (mService != null) { mService.sendCommand(BleCommand.StartSingleCapture.ordinal(), null); setGuiByAppMode(AppRunMode.ConnectedDuringSingleTransfer); } } }); mBtnStartStream.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { if (mService != null) { if (!mStreamActive) { mStreamActive = true; mService.sendCommand(BleCommand.StartStreaming.ordinal(), null); setGuiByAppMode(AppRunMode.ConnectedDuringStream); } else { mStreamActive = false; mService.sendCommand(BleCommand.StopStreaming.ordinal(), null); setGuiByAppMode(AppRunMode.Connected); } } } }); mSpinnerResolution.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() { @Override public void onItemSelected(AdapterView<?> parentView, View selectedItemView, int position, long id) { if (mService != null && mService.isConnected()) { byte[] cmdData = new byte[1]; cmdData[0] = (byte) position; mService.sendCommand(BleCommand.ChangeResolution.ordinal(), cmdData); } } @Override public void onNothingSelected(AdapterView<?> parentView) { } }); mSpinnerPhy.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() { @Override public void onItemSelected(AdapterView<?> parentView, View selectedItemView, int position, long id) { if (mService != null && mService.isConnected()) { byte[] cmdData = new byte[1]; cmdData[0] = (byte) position; mService.sendCommand(BleCommand.ChangePhy.ordinal(), cmdData); } } @Override public void onNothingSelected(AdapterView<?> parentView) { } }); // Set initial UI state guiUpdateHandler.postDelayed(guiUpdateRunnable, 0); setGuiByAppMode(AppRunMode.Disconnected); }
From source file:com.example.smsquickform.Homescreen.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_homescreen); ActivityHelper.initialize(this); //This is to ensure that the rotation persists across activities and not just this one Log.d(TAG, "Created"); Intent intent = getIntent();/*from w w w . j a v a 2s.c om*/ mBtnSearch = (Button) findViewById(R.id.btnSearch); mBtnConnect = (Button) findViewById(R.id.btnConnect); mButtonAnak = (Button) findViewById(R.id.buttonAnak); mButtonIbu = (Button) findViewById(R.id.buttonIbu); heading = (TextView) findViewById(R.id.txtListHeading); mLstDevices = (ListView) findViewById(R.id.lstDevices); /* *Check if there is a savedInstanceState. If yes, that means the onCreate was probably triggered by a configuration change *like screen rotate etc. If that's the case then populate all the views that are necessary here */ if (savedInstanceState != null) { ArrayList<BluetoothDevice> list = savedInstanceState.getParcelableArrayList(DEVICE_LIST); if (list != null) { initList(list); MyAdapter adapter = (MyAdapter) mLstDevices.getAdapter(); int selectedIndex = savedInstanceState.getInt(DEVICE_LIST_SELECTED); if (selectedIndex != -1) { adapter.setSelectedIndex(selectedIndex); mBtnConnect.setEnabled(true); } } else { initList(new ArrayList<BluetoothDevice>()); } } else { initList(new ArrayList<BluetoothDevice>()); } //IntentFilter filter = new IntentFilter(BluetoothDevice.ACTION_FOUND); //this.registerReceiver(mReceiver, filter); // Register for broadcasts when discovery has finished //filter = new IntentFilter(BluetoothAdapter.ACTION_DISCOVERY_FINISHED); //this.registerReceiver(mReceiver, filter); mBtnSearch.setOnClickListener(new OnClickListener() { List<BluetoothDevice> listDevices; @Override public void onClick(View arg0) { mBTAdapter = BluetoothAdapter.getDefaultAdapter(); heading.setText("Searching"); mBtnSearch.setEnabled(false); if (mBTAdapter == null) { Toast.makeText(getApplicationContext(), "Bluetooth not found", Toast.LENGTH_SHORT).show(); } else if (!mBTAdapter.isEnabled()) { Intent enableBT = new Intent(BluetoothAdapter.ACTION_REQUEST_ENABLE); startActivityForResult(enableBT, BT_ENABLE_REQUEST); } else { //listDevices = new ArrayList<BluetoothDevice>(); /*for (BluetoothDevice device : pairedDevices) { listDevices.add(device); }*/ new SearchDevices().execute(); } } }); mButtonIbu.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { // TODO Auto-generated method stub if (mLstDevices != null) { ArrayList<BluetoothDevice> devices = (ArrayList<BluetoothDevice>) ((MyAdapter) (mLstDevices .getAdapter())).getEntireList(); Intent intent = new Intent(getApplicationContext(), MainActivity.class); intent.putExtra(DEVICES_LISTS, devices); try { } catch (NullPointerException ex) { } intent.putExtra(DEVICE_UUID, mDeviceUUID.toString()); intent.putExtra(BUFFER_SIZE, mBufferSize); startActivity(intent); } } }); mBtnConnect.setOnClickListener(new OnClickListener() { /** * connect to all paired devices */ @Override public void onClick(View arg0) { List<BluetoothDevice> devices = ((MyAdapter) (mLstDevices.getAdapter())).getEntireList(); for (int i = 0; i < devices.size(); i++) { BluetoothDevice device = devices.get(i); msg(device.getName()); Intent intent = new Intent(getApplicationContext(), MainActivity.class); intent.putExtra(DEVICE_EXTRA, device); intent.putExtra(DEVICE_UUID, mDeviceUUID.toString()); intent.putExtra(BUFFER_SIZE, mBufferSize); startActivity(intent); } } }); }
From source file:dev.coatl.co.urband_basic.presenter.activities.StartSearchDevice.java
private void setBluetooth() { /* Verify that Android device has Bluetooth LE feature*/ if (!getPackageManager().hasSystemFeature(PackageManager.FEATURE_BLUETOOTH_LE)) { finish();//ww w .ja va 2 s. co m } /* Check if Bluetooth is enabled (ON)*/ if (!bluetoothAdapter.isEnabled()) { /* Start system activity for request to turn on the bluetooth */ Intent enableBtIntent = new Intent(BluetoothAdapter.ACTION_REQUEST_ENABLE); startActivityForResult(enableBtIntent, REQUEST_ENABLE_BT); } // Here, thisActivity is the current activity if (ContextCompat.checkSelfPermission(this, Manifest.permission.ACCESS_COARSE_LOCATION) != PackageManager.PERMISSION_GRANTED) { // Should we show an explanation? if (ActivityCompat.shouldShowRequestPermissionRationale(this, Manifest.permission.ACCESS_COARSE_LOCATION)) { // Show an expanation to the user *asynchronously* -- don't block // this thread waiting for the user's response! After the user // sees the explanation, try again to request the permission. } else { // No explanation needed, we can request the permission. ActivityCompat.requestPermissions(this, new String[] { Manifest.permission.ACCESS_COARSE_LOCATION }, my_req_perm1); // MY_PERMISSIONS_REQUEST_READ_CONTACTS is an // app-defined int constant. The callback method gets the // result of the request. } } // Here, thisActivity is the current activity if (ContextCompat.checkSelfPermission(this, Manifest.permission.ACCESS_FINE_LOCATION) != PackageManager.PERMISSION_GRANTED) { // Should we show an explanation? if (ActivityCompat.shouldShowRequestPermissionRationale(this, Manifest.permission.ACCESS_FINE_LOCATION)) { // Show an explanation to the user *asynchronously* -- don't block // this thread waiting for the user's response! After the user // sees the explanation, try again to request the permission. } else { // No explanation needed, we can request the permission. ActivityCompat.requestPermissions(this, new String[] { Manifest.permission.ACCESS_FINE_LOCATION }, my_req_perm2); // MY_PERMISSIONS_REQUEST_READ_CONTACTS is an // app-defined int constant. The callback method gets the // result of the request. } } // Here, thisActivity is the current activity if (ContextCompat.checkSelfPermission(this, Manifest.permission.WRITE_EXTERNAL_STORAGE) != PackageManager.PERMISSION_GRANTED) { // Should we show an explanation? if (ActivityCompat.shouldShowRequestPermissionRationale(this, Manifest.permission.WRITE_EXTERNAL_STORAGE)) { // Show an expanation to the user *asynchronously* -- don't block // this thread waiting for the user's response! After the user // sees the explanation, try again to request the permission. } else { // No explanation needed, we can request the permission. ActivityCompat.requestPermissions(this, new String[] { Manifest.permission.WRITE_EXTERNAL_STORAGE }, my_req_perm3); // MY_PERMISSIONS_REQUEST_READ_CONTACTS is an // app-defined int constant. The callback method gets the // result of the request. } } scanLeDevice(true); }
From source file:com.megster.cordova.ble.central.BLECentralPlugin.java
@Override public boolean execute(String action, CordovaArgs args, CallbackContext callbackContext) throws JSONException { LOG.d(TAG, "action = " + action); if (bluetoothAdapter == null) { Activity activity = cordova.getActivity(); BluetoothManager bluetoothManager = (BluetoothManager) activity .getSystemService(Context.BLUETOOTH_SERVICE); bluetoothAdapter = bluetoothManager.getAdapter(); }/*from www . j a v a 2 s . c o m*/ boolean validAction = true; if (action.equals(SCAN)) { UUID[] serviceUUIDs = parseServiceUUIDList(args.getJSONArray(0)); int scanSeconds = args.getInt(1); findLowEnergyDevices(callbackContext, serviceUUIDs, scanSeconds); } else if (action.equals(START_SCAN)) { UUID[] serviceUUIDs = parseServiceUUIDList(args.getJSONArray(0)); findLowEnergyDevices(callbackContext, serviceUUIDs, -1); } else if (action.equals(STOP_SCAN)) { bluetoothAdapter.stopLeScan(this); callbackContext.success(); } else if (action.equals(LIST)) { listKnownDevices(callbackContext); } else if (action.equals(CONNECT)) { String macAddress = args.getString(0); connect(callbackContext, macAddress); } else if (action.equals(DISCONNECT)) { String macAddress = args.getString(0); disconnect(callbackContext, macAddress); } else if (action.equals(READ)) { String macAddress = args.getString(0); UUID serviceUUID = uuidFromString(args.getString(1)); UUID characteristicUUID = uuidFromString(args.getString(2)); read(callbackContext, macAddress, serviceUUID, characteristicUUID); } else if (action.equals(WRITE)) { String macAddress = args.getString(0); UUID serviceUUID = uuidFromString(args.getString(1)); UUID characteristicUUID = uuidFromString(args.getString(2)); byte[] data = args.getArrayBuffer(3); int type = BluetoothGattCharacteristic.WRITE_TYPE_DEFAULT; write(callbackContext, macAddress, serviceUUID, characteristicUUID, data, type); } else if (action.equals(WRITE_WITHOUT_RESPONSE)) { String macAddress = args.getString(0); UUID serviceUUID = uuidFromString(args.getString(1)); UUID characteristicUUID = uuidFromString(args.getString(2)); byte[] data = args.getArrayBuffer(3); int type = BluetoothGattCharacteristic.WRITE_TYPE_NO_RESPONSE; write(callbackContext, macAddress, serviceUUID, characteristicUUID, data, type); } else if (action.equals(START_NOTIFICATION)) { String macAddress = args.getString(0); UUID serviceUUID = uuidFromString(args.getString(1)); UUID characteristicUUID = uuidFromString(args.getString(2)); registerNotifyCallback(callbackContext, macAddress, serviceUUID, characteristicUUID); } else if (action.equals(STOP_NOTIFICATION)) { String macAddress = args.getString(0); UUID serviceUUID = uuidFromString(args.getString(1)); UUID characteristicUUID = uuidFromString(args.getString(2)); removeNotifyCallback(callbackContext, macAddress, serviceUUID, characteristicUUID); } else if (action.equals(IS_ENABLED)) { if (bluetoothAdapter.isEnabled()) { callbackContext.success(); } else { callbackContext.error("Bluetooth is disabled."); } } else if (action.equals(IS_CONNECTED)) { String macAddress = args.getString(0); if (peripherals.containsKey(macAddress) && peripherals.get(macAddress).isConnected()) { callbackContext.success(); } else { callbackContext.error("Not connected."); } } else if (action.equals(SETTINGS)) { Intent intent = new Intent(Settings.ACTION_BLUETOOTH_SETTINGS); cordova.getActivity().startActivity(intent); callbackContext.success(); } else if (action.equals(ENABLE)) { enableBluetoothCallback = callbackContext; Intent intent = new Intent(BluetoothAdapter.ACTION_REQUEST_ENABLE); cordova.startActivityForResult(this, intent, REQUEST_ENABLE_BLUETOOTH); } else { validAction = false; } return validAction; }
From source file:com.androidaq.AndroiDAQMain.java
@Override public void onStart() { super.onStart(); if (D)//from w w w . j av a2 s . com Log.e(TAG, "++ ON START ++"); // If BT is not on, request that it be enabled. // setupChat() will then be called during onActivityResult if (!mBluetoothAdapter.isEnabled()) { Intent enableIntent = new Intent(BluetoothAdapter.ACTION_REQUEST_ENABLE); startActivityForResult(enableIntent, REQUEST_ENABLE_BT); // Otherwise, setup the chat session } else { if (mSerialService == null) setupChat(); } }
From source file:com.aware.plugin.polarhrm.Plugin.java
@Override public void onCreate() { super.onCreate(); TAG = "PolarHRM"; CONTEXT_PRODUCER = new Aware_Plugin.ContextProducer() { @Override// ww w . j av a 2 s. c o m public void onContext() { Intent heartRate = new Intent(ACTION_AWARE_POLAR_HEARTRATE); sendBroadcast(heartRate); } }; DATABASE_TABLES = PolarHRM_Provider.DATABASE_TABLES; TABLES_FIELDS = PolarHRM_Provider.TABLES_FIELDS; CONTEXT_URIS = new Uri[] { PolarHRM_Data.CONTENT_URI, PolarHRM_Profile.CONTENT_URI }; notManager = (NotificationManager) getSystemService(NOTIFICATION_SERVICE); notificationBuilder = new NotificationCompat.Builder(this); IntentFilter filter = new IntentFilter(BluetoothAdapter.ACTION_STATE_CHANGED); registerReceiver(btStateListener, filter); prefs = getSharedPreferences(getPackageName(), MODE_MULTI_PROCESS); if (btAdapter != null && !btAdapter.isEnabled()) { Intent makeEnabled = new Intent(BluetoothAdapter.ACTION_REQUEST_ENABLE); makeEnabled.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_BROUGHT_TO_FRONT); startActivity(makeEnabled); } updater = new Timer(); updater.scheduleAtFixedRate(updateHR, 0, 2000); if (!prefs.contains("age")) { Intent hrm_params = new Intent(getApplicationContext(), Settings.class); hrm_params.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); startActivity(hrm_params); } else { algorithm = new Algorithm(prefs.getInt("age", 25), prefs.getInt("rhr", 70)); SparseArray<double[]> hr_zones = algorithm.getZones(); ContentValues rowData = new ContentValues(); rowData.put(PolarHRM_Profile.TIMESTAMP, System.currentTimeMillis()); rowData.put(PolarHRM_Profile.DEVICE_ID, Aware.getSetting(getContentResolver(), Aware_Preferences.DEVICE_ID)); rowData.put(PolarHRM_Profile.AGE, prefs.getInt("age", 25)); rowData.put(PolarHRM_Profile.RESTING_HR, prefs.getInt("rhr", 70)); rowData.put(PolarHRM_Profile.RECOVERY_MIN, hr_zones.get(0)[0]); rowData.put(PolarHRM_Profile.RECOVERY_MAX, hr_zones.get(0)[1]); rowData.put(PolarHRM_Profile.AEROBIC_MIN, hr_zones.get(1)[0]); rowData.put(PolarHRM_Profile.AEROBIC_MAX, hr_zones.get(1)[1]); rowData.put(PolarHRM_Profile.ANAEROBIC_MIN, hr_zones.get(2)[0]); rowData.put(PolarHRM_Profile.ANAEROBIC_MAX, hr_zones.get(2)[1]); rowData.put(PolarHRM_Profile.RED_LINE_MIN, hr_zones.get(3)[0]); rowData.put(PolarHRM_Profile.RED_LINE_MAX, hr_zones.get(3)[1]); getContentResolver().insert(PolarHRM_Profile.CONTENT_URI, rowData); } showUI(); }
From source file:com.github.google.beaconfig.ScanningActivity.java
private void requestBluetoothOn() { if (btAdapter == null || !btAdapter.isEnabled()) { Log.d(TAG, "Bluetooth not enabled, requesting permission."); Intent enableBtIntent = new Intent(BluetoothAdapter.ACTION_REQUEST_ENABLE); this.startActivityForResult(enableBtIntent, Constants.REQUEST_ENABLE_BLUETOOTH); } else if (scanner == null) { scanner = new BeaconScanner(this, btAdapter); scan();//from w w w . j av a 2 s . co m } }