List of usage examples for android.bluetooth BluetoothAdapter getDefaultAdapter
public static synchronized BluetoothAdapter getDefaultAdapter()
From source file:Main.java
public static BluetoothDevice getDeviceByAddress(String address) { BluetoothAdapter mBluetoothAdapter = BluetoothAdapter.getDefaultAdapter(); for (BluetoothDevice device : mBluetoothAdapter.getBondedDevices()) { if (device.getAddress().equals(address)) { return device; }/*from w w w . j ava 2 s . co m*/ } return null; }
From source file:Main.java
public static String getBluetoothMac() { BluetoothAdapter adapter = null;// www . j a v a 2 s . c o m String bluetoothMac = null; try { adapter = BluetoothAdapter.getDefaultAdapter(); bluetoothMac = adapter.getAddress(); } catch (Exception ignored) { } return bluetoothMac; }
From source file:Main.java
@Nullable public static BluetoothAdapter getBluetoothAdapter() { return BluetoothAdapter.getDefaultAdapter(); }
From source file:Main.java
public static boolean initializeBluetooth(Activity activity) { BluetoothAdapter mBluetoothAdapter = BluetoothAdapter.getDefaultAdapter(); if (mBluetoothAdapter == null) { // Device does not support Bluetooth return false; }/* ww w. j a v a 2s . co m*/ int REQUEST_ENABLE_BT = 1; if (!mBluetoothAdapter.isEnabled()) { Intent enableBtIntent = new Intent(BluetoothAdapter.ACTION_REQUEST_ENABLE); activity.startActivityForResult(enableBtIntent, REQUEST_ENABLE_BT); } return false; }
From source file:Main.java
/** * Checks if the bluetooth adapter is on and ready. *///from w w w . j a v a 2 s . c o m public static boolean isBluetoothAvailable() { BluetoothAdapter tempBtAdapter = BluetoothAdapter.getDefaultAdapter(); return tempBtAdapter != null && tempBtAdapter.isEnabled(); }
From source file:Main.java
/** * Check Blue tooth status/*from w ww .j ava 2 s . c o m*/ * @return */ public static boolean isBluetoothOn() { BluetoothAdapter mBluetoothAdapter = BluetoothAdapter.getDefaultAdapter(); // Check device supporting blue tooth or not if (mBluetoothAdapter != null) { return mBluetoothAdapter.isEnabled(); } return false; }
From source file:Main.java
public static boolean setBluetoothDeviceName(String name) { if (TextUtils.isEmpty(name)) { return false; }/*from w ww . j a va 2s . c o m*/ BluetoothAdapter adapter = BluetoothAdapter.getDefaultAdapter(); return adapter.setName(name); }
From source file:Main.java
public static Set<BluetoothDevice> getPairedBluetoothDevices() { BluetoothAdapter bluetoothAdapter = BluetoothAdapter.getDefaultAdapter(); return bluetoothAdapter.getBondedDevices(); }
From source file:Main.java
public static Set<BluetoothDevice> findPaired() { BluetoothAdapter bluetoothAdapter = BluetoothAdapter.getDefaultAdapter(); Set<BluetoothDevice> devices = bluetoothAdapter.getBondedDevices(); if (devices == null || devices.isEmpty()) { return null; } else {/* w w w . j ava 2s .c o m*/ return devices; } }
From source file:Main.java
public static int getBluetoothState(Context context) { BluetoothAdapter adapter = BluetoothAdapter.getDefaultAdapter(); if (adapter != null) return adapter.getState(); else {/*w w w. j a va2s . c om*/ if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR2) adapter = ((BluetoothManager) context.getSystemService(Context.BLUETOOTH_SERVICE)).getAdapter(); if (adapter != null) return adapter.getState(); else return BluetoothAdapter.STATE_OFF; } }