Java 显示Android蓝牙设备名称
如何在使用Java的android中显示蓝牙设备名称?有我要参考的代码吗?下面的代码将得到你的蓝牙名称,这里的Java 显示Android蓝牙设备名称,java,android,eclipse,bluetooth,device-name,Java,Android,Eclipse,Bluetooth,Device Name,如何在使用Java的android中显示蓝牙设备名称?有我要参考的代码吗?下面的代码将得到你的蓝牙名称,这里的mBluetoothAdapter是BluetoothAdapter类型 public String getLocalBluetoothName(){ if(mBluetoothAdapter == null){ mBluetoothAdapter = BluetoothAdapter.getDefaultAdapter(); } String
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;
}
谢谢你,侯赛因!它与我的代码配合得很好。但是,如果我要检索手机地址,也可以采用相同的方式?
import android.provider.Settings.Secure;私有字符串android\u id=Secure.getString(getContext().getContentResolver(),Secure.android)代码>这将有助于获取android的唯一iddevice@TunA:TelephonyManager tManager=(TelephonyManager)myActivity.getSystemService(Context.TELEPHONY_服务);字符串uid=tManager.getDeviceId()代码>活动类。getDeviceID()将返回设备的MDN或MEID,具体取决于手机使用的无线电设备(GSM或CDMA)。但是,我要检索的是android设备的序列号,而不是连接到PC的蓝牙设备的手机地址。。你有什么办法可以向我解释清楚吗?你需要蓝牙设备的地址吗?