6

Javaを使用するAndroidでBluetoothデバイス名を表示するには? 参照するコードはありますか?

4

1 に答える 1

18

以下のコードは、Bluetooth 名を取得します。ここでmBluetoothAdapterは、タイプはBluetoothAdapterです。

  public String getLocalBluetoothName(){
    if(mBluetoothAdapter == null){
        mBluetoothAdapter = BluetoothAdapter.getDefaultAdapter();
    }
    String name = mBluetoothAdapter.getName();
    if(name == null){
        System.out.println("Name is null!");
        name = mBluetoothAdapter.getAddress();
    }
    return name;
}
于 2011-07-12T09:48:16.107 に答える