0
我在使用藍牙連接Android應用工作檢測來自藍牙設備活動的連接,我想從設備的數據讀入的應用程序,但需要知道,如果我連接到設備讀取數據之前。如何使用Android SDK
下面是我有啓動藍牙設置,我可以配對的設備代碼。如何驗證已配對的設備是否具有與應用程序的活動連接並準備好發送數據?
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_connect);
Button btn = (Button) findViewById(R.id.connect_button);
btn.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent intentOpenBluetoothSettings = new Intent();
intentOpenBluetoothSettings.setAction(android.provider.Settings.ACTION_BLUETOOTH_SETTINGS);
startActivity(intentOpenBluetoothSettings);
}
});
mBluetoothAdapter = BluetoothAdapter.getDefaultAdapter();
pairedDevices = mBluetoothAdapter.getBondedDevices();