List of usage examples for android.bluetooth BluetoothDevice getName
@RequiresPermission(Manifest.permission.BLUETOOTH)
public String getName()
From source file:Main.java
/** * Turns the #BluetoothDevice into a human-readable string. */// w w w. j a va 2s . c o m public static String getDisplayString(BluetoothDevice device) { String name = device.getName(); String address = device.getAddress(); if (name == null) return address; return name + " [" + address + "]"; }
From source file:Main.java
public static boolean checkMusePaired() { Set<BluetoothDevice> devices = findPaired(); if (devices == null || devices.isEmpty()) { return false; }/*from w w w . java2 s . c o m*/ for (BluetoothDevice device : devices) { if (device.getName().equalsIgnoreCase("muse")) { return true; } } return false; }
From source file:Main.java
public static String printDevice(BluetoothDevice device) { return String.format("%s; %s; %s; %s", device.getAddress(), device.getName(), device.getType(), device.getBluetoothClass()); }
From source file:Main.java
public static String getDeviceInfoText(BluetoothDevice device, int rssi, byte[] scanRecord) { return new StringBuilder().append("Name: ").append(device.getName()).toString(); }
From source file:Main.java
public static final String[] getBondedDeviceNames() { BluetoothAdapter adapter = BluetoothAdapter.getDefaultAdapter(); Set<BluetoothDevice> devices = adapter.getBondedDevices(); String[] names = new String[devices.size()]; int i = 0;//from www .j a v a2s .com for (BluetoothDevice d : devices) { Log.d(TAG, "Found bonded device " + d.getName()); names[i++] = d.getName(); } return names; }
From source file:Main.java
public static String formatGattShort(BluetoothGatt gatt) { BluetoothDevice device = gatt.getDevice(); String log = ""; if (device != null) log += device.getName(); else//from w w w . ja v a 2s .co m log += "unknown"; return log; }
From source file:Main.java
private static String convertBluetoothDevice(BluetoothDevice device) { String list;//from www.j ava 2s .co m list = "Address: " + device.getAddress(); list += ", Name: " + device.getName(); list += ", Class: " + device.getBluetoothClass(); list += ", State: " + device.getBondState(); list += "\n\n"; return list; }
From source file:com.variable.demo.api.fragment.MainOptionsFragment.java
/** * Initiates a connection with the selected device. * @param device/*from w w w. j a v a 2 s . co m*/ */ private static void onDeviceSelected(BluetoothDevice device) { Log.d("", "Selected Device Name" + device.getName()); BluetoothService mService = NodeApplication.getService(); NodeDevice node = NodeApplication.getActiveNode(); if (mService != null) { //One way to connect to a device //mService.connect(device.getAddress()); //Second way, using the NodeDevice implementation NodeDevice selectedNODE = AndroidNodeDevice.getOrCreateNodeFromBluetoothDevice(device, new DefaultBluetoothDevice(mService)); //Ensure One Connection At a Time... if (node != null && !selectedNODE.equals(node) && node.isConnected()) { node.disconnect(); } //Store the Active NODE in the application space for other fragments to use NodeApplication.setActiveNode(selectedNODE); //initiate connection selectedNODE.connect(); } }
From source file:com.variable.demo.api.fragment.MainOptionsFragment.java
/** * Shows a Dialog for any bonded device. * * Additionally, when item is select, onDeviceSelected is invoked. * @param c/*from w ww . j a va2s . co m*/ */ public static void showPairedNodesDialog(Context c) { //Only Allow One Occurence of the Dialog to be Shown. if (mDevicesDialog != null) { mDevicesDialog.dismiss(); } final Set<BluetoothDevice> mBondedDevices = BluetoothAdapter.getDefaultAdapter().getBondedDevices(); final String[] bluetoothNames = new String[mBondedDevices.size()]; int i = 0; for (BluetoothDevice device : mBondedDevices) { bluetoothNames[i++] = device.getName(); } //Build the Dialog mDevicesDialog = new AlertDialog.Builder(c).setTitle("Select a NODE") .setItems(bluetoothNames, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialogInterface, int position) { int index = 0; for (BluetoothDevice device : mBondedDevices) { if (index++ == position) { onDeviceSelected(device); } } } }).setNegativeButton("Cancel", null).create(); //Show the Dialog mDevicesDialog.show(); }
From source file:co.aurasphere.bluepair.bluetooth.BluetoothController.java
/** * Gets the name of a device. If the device name is not available, returns the device address. * * @param device the device whose name to return. * @return the name of the device or its address if the name is not available. *//* ww w . j a v a2s . c om*/ public static String getDeviceName(BluetoothDevice device) { String deviceName = device.getName(); if (deviceName == null) { deviceName = device.getAddress(); } return deviceName; }