List of usage examples for android.content Context BLUETOOTH_SERVICE
String BLUETOOTH_SERVICE
To view the source code for android.content Context BLUETOOTH_SERVICE.
Click Source Link
From source file:top.isense.demo.testsensor.DeviceScanActivity.java
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); initial_naviview(this); //getActionBar().setTitle(R.string.title_devices); mHandler = new Handler(); // Use this check to determine whether BLE is supported on the device. Then you can // selectively disable BLE-related features. if (!getPackageManager().hasSystemFeature(PackageManager.FEATURE_BLUETOOTH_LE)) { Toast.makeText(this, R.string.ble_not_supported, Toast.LENGTH_SHORT).show(); finish();/*from www . jav a2s . co m*/ } // Initializes a Bluetooth adapter. For API level 18 and above, get a reference to // BluetoothAdapter through BluetoothManager. final BluetoothManager bluetoothManager = (BluetoothManager) getSystemService(Context.BLUETOOTH_SERVICE); mBluetoothAdapter = bluetoothManager.getAdapter(); // Checks if Bluetooth is supported on the device. if (mBluetoothAdapter == null) { Toast.makeText(this, R.string.error_bluetooth_not_supported, Toast.LENGTH_SHORT).show(); finish(); return; } }
From source file:za.co.paulscott.antifitness.ModuleActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); final BluetoothManager bluetoothManager = (BluetoothManager) getSystemService(Context.BLUETOOTH_SERVICE); if (!bluetoothManager.getAdapter().isEnabled()) { final Intent enableIntent = new Intent(BluetoothAdapter.ACTION_REQUEST_ENABLE); startActivityForResult(enableIntent, REQUEST_ENABLE_BT); }//from www . j a v a 2 s .c o m getApplicationContext().bindService(new Intent(this, MetaWearBLEService.class), this, Context.BIND_AUTO_CREATE); if (savedInstanceState != null) { device = (BluetoothDevice) savedInstanceState.getParcelable(EXTRA_BLE_DEVICE); moduleFragment = (ModuleFragment) getSupportFragmentManager().getFragment(savedInstanceState, "mContent"); } }
From source file:com.example.shahrukhqasim2.deepmount.DeviceScanActivity.java
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); getActionBar().setTitle(R.string.title_devices); mHandler = new Handler(); if (!checkPermission(this)) showPermissionDialog();// w w w. j a va2 s . co m // Use this check to determine whether BLE is supported on the device. Then you can // selectively disable BLE-related features. if (!getPackageManager().hasSystemFeature(PackageManager.FEATURE_BLUETOOTH_LE)) { Toast.makeText(this, R.string.ble_not_supported, Toast.LENGTH_SHORT).show(); finish(); } // Initializes a Bluetooth adapter. For API level 18 and above, get a reference to // BluetoothAdapter through BluetoothManager. final BluetoothManager bluetoothManager = (BluetoothManager) getSystemService(Context.BLUETOOTH_SERVICE); mBluetoothAdapter = bluetoothManager.getAdapter(); // Checks if Bluetooth is supported on the device. if (mBluetoothAdapter == null) { Toast.makeText(this, R.string.error_bluetooth_not_supported, Toast.LENGTH_SHORT).show(); finish(); return; } }
From source file:org.physical_web.physicalweb.PhysicalWebBroadcastService.java
@Override public void onCreate() { super.onCreate(); Log.d(TAG, "SERVICE onCreate"); BluetoothManager bluetoothManager = (BluetoothManager) getApplicationContext() .getSystemService(Context.BLUETOOTH_SERVICE); mBluetoothLeAdvertiser = bluetoothManager.getAdapter().getBluetoothLeAdvertiser(); mNotificationManager = NotificationManagerCompat.from(this); }
From source file:iha_au.ppmonitor.Services.BleService.java
/** * Nr BleService bliver startet kaldes onCreate. Det er her alle attributter bliver instantieret. *//*from www .j a va2 s .c o m*/ @Override public void onCreate() { // BluetoothManager bruges til at manage og tilg BlueToothAdapter. bluetoothManager = (BluetoothManager) getSystemService(Context.BLUETOOTH_SERVICE); // BlueToothAdapter reprsentere enhedens lokale bluetoothadapter. Det er denne klasse, som bruges til at kalde Bluetooth tasks. mBluetoothAdapter = bluetoothManager.getAdapter(); // Gennem denne klasse kan der scannes for Low Energy Bluetooth apparater. bluetoothLeScanner = mBluetoothAdapter.getBluetoothLeScanner(); hasBle = getPackageManager().hasSystemFeature(PackageManager.FEATURE_BLUETOOTH_LE); //Metode til afkodning af UUIDS, da disse en collection af bytes. afkodes de til string, for nemmere sammenligning. try { getUuidsMethod = mBluetoothAdapter.getClass().getDeclaredMethod("getUuids", null); } catch (NoSuchMethodException e) { e.printStackTrace(); } Log.v("DEBUG", "bleservce is started"); super.onCreate(); }
From source file:org.chromium.ChromeBluetooth.java
@Override protected void pluginInitialize() { registerAdapterStateReceiver();// w ww . j ava 2 s. c o m bluetoothManager = (BluetoothManager) webView.getContext().getSystemService(Context.BLUETOOTH_SERVICE); bluetoothAdapter = bluetoothManager.getAdapter(); leScanner = BluetoothLeScannerCompatProvider.getBluetoothLeScannerCompat(webView.getContext()); isLeScanning = false; enableBluetooth(); }
From source file:com.android.waleed.arduino101led.DeviceScanActivity.java
@Override public void onCreate(Bundle savedInstanceState) { requestLocationUpdates();//from ww w. java 2 s . c o m super.onCreate(savedInstanceState); getActionBar().setTitle(R.string.title_devices); mHandler = new Handler(); // Use this check to determine whether BLE is supported on the device. Then you can // selectively disable BLE-related features. if (!getPackageManager().hasSystemFeature(PackageManager.FEATURE_BLUETOOTH_LE)) { Toast.makeText(this, R.string.ble_not_supported, Toast.LENGTH_SHORT).show(); finish(); } // Initializes a Bluetooth adapter. For API level 18 and above, get a reference to // BluetoothAdapter through BluetoothManager. final BluetoothManager bluetoothManager = (BluetoothManager) getSystemService(Context.BLUETOOTH_SERVICE); mBluetoothAdapter = bluetoothManager.getAdapter(); // Checks if Bluetooth is supported on the device. if (mBluetoothAdapter == null) { Toast.makeText(this, R.string.error_bluetooth_not_supported, Toast.LENGTH_SHORT).show(); finish(); return; } }
From source file:com.mikel.poseidon.Activities.preferences.BluetoothDeviceActivity.java
@Override protected void onResume() { super.onResume(); final BluetoothManager bluetoothManager = (BluetoothManager) getSystemService(Context.BLUETOOTH_SERVICE); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR2) { mBluetoothAdapter = bluetoothManager.getAdapter(); }/*from w ww . j a v a2 s.c o m*/ if (!mBluetoothAdapter.isEnabled()) { if (!mBluetoothAdapter.isEnabled()) { Intent enableBtIntent = new Intent(BluetoothAdapter.ACTION_REQUEST_ENABLE); startActivityForResult(enableBtIntent, 1); } } mPairedDevice = mSettings.getString("macaddress", ""); if (!mPairedDevice.isEmpty()) { BluetoothDevice bluetoothDevice = new BluetoothDevice(); bluetoothDevice.macaddress = mPairedDevice; bluetoothDevice.name = "Currently not found"; bluetoothDevice.checked = true; bluetoothDevice.rssi = -1000; mFragment.foundDevice(bluetoothDevice); } }
From source file:com.mbientlab.metawear.app.ModuleActivity.java
@SuppressWarnings("unchecked") @Override/*from www. j a v a2s . c om*/ protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); final BluetoothManager bluetoothManager = (BluetoothManager) getSystemService(Context.BLUETOOTH_SERVICE); if (!bluetoothManager.getAdapter().isEnabled()) { final Intent enableIntent = new Intent(BluetoothAdapter.ACTION_REQUEST_ENABLE); startActivityForResult(enableIntent, REQUEST_ENABLE_BT); } getApplicationContext().bindService(new Intent(this, MetaWearBleService.class), this, Context.BIND_AUTO_CREATE); if (savedInstanceState != null) { device = (BluetoothDevice) savedInstanceState.getParcelable(EXTRA_BLE_DEVICE); moduleFragment = (ModuleFragment) getSupportFragmentManager().getFragment(savedInstanceState, "mContent"); tapType = savedInstanceState.getInt(Extra.TAP_TYPE); tapAxis = savedInstanceState.getInt(Extra.TAP_AXIS); shakeAxis = savedInstanceState.getInt(Extra.SHAKE_AXIS); dataRange = savedInstanceState.getInt(Extra.DATA_RANGE); samplingRate = savedInstanceState.getInt(Extra.SAMPLING_RATE); ffMovement = savedInstanceState.getBoolean(Extra.FF_MOVEMENT); newFirmware = savedInstanceState.getBoolean(Extra.NEW_FIRMWARE); samplingConfigBytes = savedInstanceState.getByteArray(Extra.SAMPLING_CONFIG_BYTES); polledData = (ArrayList<byte[]>) savedInstanceState.getSerializable(Extra.POLLED_DATA); } }
From source file:com.xiaocheng.xc_application.bluetoothutils.DeviceScanActivity.java
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.view_bluetooth_list); //getActionBar().setTitle(R.string.title_devices); mHandler = new Handler(); //???/* w w w.j a v a 2s. c o m*/ if (ContextCompat.checkSelfPermission(this, Manifest.permission.ACCESS_COARSE_LOCATION) != PackageManager.PERMISSION_GRANTED) { //?? ActivityCompat.requestPermissions(this, new String[] { Manifest.permission.ACCESS_COARSE_LOCATION }, /*MY_PERMISSIONS_REQUEST_ACCESS_COARSE_LOCATION*/0); //?? ???? if (ActivityCompat.shouldShowRequestPermissionRationale(this, Manifest.permission.READ_CONTACTS)) { Toast.makeText(this, "shouldShowRequestPermissionRationale", Toast.LENGTH_SHORT).show(); } } // Use this check to determine whether BLE is supported on the device. Then you can // selectively disable BLE-related features. if (!getPackageManager().hasSystemFeature(PackageManager.FEATURE_BLUETOOTH_LE)) { Toast.makeText(this, R.string.ble_not_supported, Toast.LENGTH_SHORT).show(); finish(); } // Initializes a Bluetooth adapter. For API level 18 and above, get a reference to // BluetoothAdapter through BluetoothManager. final BluetoothManager bluetoothManager = (BluetoothManager) getSystemService(Context.BLUETOOTH_SERVICE); mBluetoothAdapter = bluetoothManager.getAdapter(); // Checks if Bluetooth is supported on the device. if (mBluetoothAdapter == null || !mBluetoothAdapter.isEnabled()) { /* Toast.makeText(this, R.string.error_bluetooth_not_supported, Toast.LENGTH_SHORT).show(); finish(); return;*/ Intent enableBtIntent = new Intent(BluetoothAdapter.ACTION_REQUEST_ENABLE); startActivityForResult(enableBtIntent, REQUEST_ENABLE_BT); } lv_bleList = (ListView) findViewById(R.id.lv_bleList); mDevListAdapter = new DeviceListAdapter(); lv_bleList.setAdapter(mDevListAdapter); lv_bleList.setOnItemClickListener(new OnItemClickListener() { @Override public void onItemClick(AdapterView<?> parent, View view, int position, long id) { if (mDevListAdapter.getCount() > 0) { BluetoothDevice device1 = mDevListAdapter.getItem(position); if (device1 == null) return; Intent intent1 = new Intent(); intent1.putExtra(EXTRAS_DEVICE_NAME, device1.getName()); intent1.putExtra(EXTRAS_DEVICE_ADDRESS, device1.getAddress()); if (mScanning) { mBluetoothAdapter.stopLeScan(mLeScanCallback); mScanning = false; } // setResult intent data Activity setResult(Activity.RESULT_OK, intent1); //? Activity finish(); // startActivity(intent1); } } }); }