本文整理汇总了Java中android.bluetooth.BluetoothAdapter.getName方法的典型用法代码示例。如果您正苦于以下问题:Java BluetoothAdapter.getName方法的具体用法?Java BluetoothAdapter.getName怎么用?Java BluetoothAdapter.getName使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.bluetooth.BluetoothAdapter
的用法示例。
在下文中一共展示了BluetoothAdapter.getName方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: logStatus
import android.bluetooth.BluetoothAdapter; //导入方法依赖的package包/类
public void logStatus() {
if (true) return; // NOPMD
String message = "";
if (service == null) {
message = "No swap service";
} else {
String bluetooth = service.getBluetoothSwap().isConnected() ? "Y" : " N";
String wifi = service.getWifiSwap().isConnected() ? "Y" : " N";
String mdns = service.getWifiSwap().getBonjour().isConnected() ? "Y" : " N";
message += "Swap { BT: " + bluetooth + ", WiFi: " + wifi + ", mDNS: " + mdns + "}, ";
BluetoothAdapter adapter = BluetoothAdapter.getDefaultAdapter();
bluetooth = "N/A";
if (adapter != null) {
Map<Integer, String> scanModes = new HashMap<>(3);
scanModes.put(BluetoothAdapter.SCAN_MODE_CONNECTABLE, "CON");
scanModes.put(BluetoothAdapter.SCAN_MODE_CONNECTABLE_DISCOVERABLE, "CON_DISC");
scanModes.put(BluetoothAdapter.SCAN_MODE_NONE, "NONE");
bluetooth = "\"" + adapter.getName() + "\" - " + scanModes.get(adapter.getScanMode());
}
message += "Find { BT: " + bluetooth + ", WiFi: " + wifi + "}";
}
Date now = new Date();
Utils.debugLog("Swap Status", now.getHours() + ":" + now.getMinutes() + ":" + now.getSeconds() + " " + message);
new Timer().schedule(new TimerTask() {
@Override
public void run() {
new SwapDebug().logStatus();
}
}, 1000
);
}
示例2: getBluetoothName
import android.bluetooth.BluetoothAdapter; //导入方法依赖的package包/类
public String getBluetoothName() {
try {
BluetoothAdapter defaultAdapter = BluetoothAdapter.getDefaultAdapter();
if (defaultAdapter != null) {
return defaultAdapter.getName();
}
} catch (Throwable e) {
Ln.e(e);
}
return null;
}
示例3: getOurDeviceName
import android.bluetooth.BluetoothAdapter; //导入方法依赖的package包/类
public static String getOurDeviceName() {
BluetoothAdapter myDevice = BluetoothAdapter.getDefaultAdapter();
if (myDevice != null)
return myDevice.getName();
return null;
}