private BluetoothAdapter bluetoothAdapter = null; bluetoothAdapter = BluetoothAdapter.getDefaultAdapter(); void ChangeDeviceName(){ Log.i(LOG, "localdevicename : "+bluetoothAdapter.getName()+" localdeviceAddress : "+bluetoothAdapter.getAddress()); bluetoothAdapter.setName("NewDeviceName"); Log.i(LOG, "localdevicename : "+bluetoothAdapter.getName()+" localdeviceAddress : "+bluetoothAdapter.getAddress()); }
String m_szBTMAC = m_BluetoothAdapter.getAddress(); System.out.println("m_szBTMAC "+m_szBTMAC);
@Test public void canGetAndSetAddress() throws Exception { BluetoothAdapter adapter = BluetoothAdapter.getDefaultAdapter(); shadowOf(adapter).setAddress("expected"); assertThat(adapter.getAddress()).isEqualTo("expected"); }
private BluetoothAdapter mBtAdapter; // Get the local Bluetooth adapter mBtAdapter = BluetoothAdapter.getDefaultAdapter(); String deviceMacAddress = mBtAdapter.getAddress();
/** * Get the MAC address of this device's Bluetooth adapter. * * @return the MAC address of the local Bluetooth adapter */ public String getLocalAdapterAddress() { return mAdapter.getAddress(); }
String strAddress = null; BluetoothAdapter bluetoothAdapter = BluetoothAdapter.getDefaultAdapter(); // if device does not support Bluetooth if(bluetoothAdapter==null){ Log.d(TAG,"device doesn't supports bluetooth"); // like in case of emulator strAddress = null; } else strAddress = bluetoothAdapter.getAddress();
BluetoothAdapter mBluetoothAdapter = BluetoothAdapter.getDefaultAdapter(); // if device does not support Bluetooth if(mBluetoothAdapter==null){ Log.d(TAG,"device does not support bluetooth"); return null; } return mBluetoothAdapter.getAddress();
BluetoothAdapter m_BluetoothAdapter = null; // Local Bluetooth adapter m_BluetoothAdapter = BluetoothAdapter.getDefaultAdapter(); String m_szBTMAC = m_BluetoothAdapter.getAddress();
BluetoothAdapter btAdapter = BluetoothAdapter.getDefaultAdapter(); if (btAdapter != null) { String mac = btAdapter.getAddress(); }
/** * get bluetooth adapter MAC address * @return MAC address String */ public static String getBluetoothMacAddress() { BluetoothAdapter mBluetoothAdapter = BluetoothAdapter.getDefaultAdapter(); // if device does not support Bluetooth if(mBluetoothAdapter==null){ Log.d(TAG,"device does not support bluetooth"); return null; } return mBluetoothAdapter.getAddress(); }
BluetoothAdapter m_BluetoothAdapter = BluetoothAdapter.getDefaultAdapter(); String m_bluetoothAdd = m_BluetoothAdapter.getAddress();
BluetoothAdapter m_BluetoothAdapter = BluetoothAdapter.getDefaultAdapter(); String m_bluetoothAdd = m_BluetoothAdapter.getAddress();
/** * Return true if Bluetooth is available. * * @return true if bluetoothAdapter is not null or it's address is empty, otherwise Bluetooth is * not supported on this hardware platform */ public boolean isBluetoothAvailable() { return !(bluetoothAdapter == null || TextUtils.isEmpty(bluetoothAdapter.getAddress())); }
public boolean isBluetoothAvailable() { try { if (mBluetoothAdapter == null || mBluetoothAdapter.getAddress().equals(null)) return false; } catch (NullPointerException e) { return false; } return true; }
BluetoothAdapter btAdapter = BluetoothAdapter.getDefaultAdapter(); String btAddress = "No Bluetooth"; if (btAdapter != null) btAddress = btAdapter.getAddress(); // Reconstitute the pairing device name from the model and the last 4 digits of the bluetooth MAC String wearName; if ((btAddress != null) && (!btAddress.equals("No Bluetooth"))) { wearName = android.os.Build.MODEL; String[] tokens = btAddress.split(":"); wearName += " " + tokens[4] + tokens[5]; wearName = wearName.toUpperCase(); } else { wearName = "No Bluetooth"; }
public static String getBtMac() { mBtMac = BluetoothAdapter.getDefaultAdapter().getAddress(); if (!TextUtils.isEmpty(mBtMac)) { mBtMac = mBtMac.replace(":", ""); return mBtMac; } else { return ""; } }
runOnUiThread(new Runnable() { public void run() { BluetoothAdapter ba; if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR2) { ba = (BluetoothAdapter) getSystemService(Context.BLUETOOTH_SERVICE); } else { ba = BluetoothAdapter.getDefaultAdapter(); } Log.i("TEST", ba.getAddress()); } });
public static String GetLocalMacAddress() { String mac = null; try { BluetoothAdapter btAda = BluetoothAdapter.getDefaultAdapter(); mac = btAda.getAddress(); } catch (Exception e) { e.printStackTrace(); } return mac; }
public static String getLocalBluetoothName(){ String name = null; BluetoothAdapter adapter = BluetoothAdapter.getDefaultAdapter(); if (adapter == null) { //System.out.println("Can't get adapter"); Log.d(TAG, "Can't get adapter"); return name; } if ((name = adapter.getName()) == null) { //System.out.println("Name is null!"); Log.d(TAG, "Name is null!"); name = adapter.getAddress(); } return name; }
public static String getAddress() { return BluetoothAdapter.getDefaultAdapter().getAddress(); }