0
デバイスが切断されたときに発生するAndroid.Bluetooth
クラスのイベントはありますか?XamarinフォームとBluetoothの切断
デバイスが切断されたときに発生するAndroid.Bluetooth
クラスのイベントはありますか?XamarinフォームとBluetoothの切断
あなたはBluetoothGattCallback
public class MyGattCallback : BluetoothGattCallback
{
public override void OnConnectionStateChange(BluetoothGatt gatt, GattStatus status, ProfileState newState)
{
base.OnConnectionStateChange(gatt, status, newState);
if(newState == ProfileState.Disconnected)
{
// disconnected
}
}
}
を追加設定する必要があり、あなたのデバイスを接続したとき、あなたはそれを渡す:
BluetoothDevice device = ...;
var callback = new MyGattCallback();
device.ConnectGatt(Application.Context, false, callback);
こんにちは、返事をありがとう。コードvar callback = new BluetoothGattCallback();あたりです?または、var callback = new MyGattCallback();という意味ですか?ありがとう – Mattekr
もちろん私は '新しいMyGattCallback()'を意味します。申し訳ありません –
こんにちは、LEのBluetoothデバイスでも動作しますか? – Mattekr