Android 如何连接到已配对的设备?
我已经准备好了我的用户接口,但我真的被困在了如何创建逻辑来连接到我手机上已经配对的设备上?。。。。我对这一切都很陌生,我会感谢你的帮助 这是我如何获得Main.java文件的:Android 如何连接到已配对的设备?,android,bluetooth,Android,Bluetooth,我已经准备好了我的用户接口,但我真的被困在了如何创建逻辑来连接到我手机上已经配对的设备上?。。。。我对这一切都很陌生,我会感谢你的帮助 这是我如何获得Main.java文件的: package com.example.mustangsound; import android.os.Bundle; import android.app.Activity; import android.view.Menu; import android.bluetooth.BluetoothAdapter;
package com.example.mustangsound;
import android.os.Bundle;
import android.app.Activity;
import android.view.Menu;
import android.bluetooth.BluetoothAdapter;
import android.bluetooth.BluetoothDevice;
import android.bluetooth.BluetoothSocket;
public class MainActivity extends Activity {
BluetoothAdapter mBluetoothAdapter;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
}
public void BTConnect (){
}
public void LightsOn (){
}
public void LightsOff (){
}
public void DoorsOpen (){
}
public void DoorsClose (){
}
public void SysOn (){
}
public void SysOff (){
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.main, menu);
return true;
}
}
我想在公共void BTConnect()中添加代码。再次感谢您的帮助。BluetoothDevice=mBluetoothAdapter.getRemoteDevice(“设备的蓝牙地址在这里”) 然后调用BluetoothDevice方法来建立任何类型的连接。例如,RFCOMM连接如下所示: BluetoothSocket=device.createInsurerCommsocketToServiceRecord(UUID.fromString(“0000111F-0000-1000-8000-00805F9B34FB”)
对于免提设备。好吧,它是什么类型的设备,支持什么配置文件。另外,您想建立什么样的蓝牙连接?我正在使用它作为连接到Arduino UNO板的蓝牙接收器: