From 94d717e41999a0dc0a7035cbcb2c19c525e91d23 Mon Sep 17 00:00:00 2001 From: Asura146 Date: Tue, 23 Jan 2024 02:47:31 +0900 Subject: [PATCH] =?UTF-8?q?=E3=82=B3=E3=83=A1=E3=83=B3=E3=83=88=E3=82=92?= =?UTF-8?q?=E8=BF=BD=E5=8A=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/example/childguard/TestService.java | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/app/src/main/java/com/example/childguard/TestService.java b/app/src/main/java/com/example/childguard/TestService.java index a16628e..b567cff 100644 --- a/app/src/main/java/com/example/childguard/TestService.java +++ b/app/src/main/java/com/example/childguard/TestService.java @@ -222,11 +222,11 @@ public class TestService extends Service { } - - - - + /** + * registerReceiverを呼び出すためのメソッド + */ public void Bluetooth_status() { + IntentFilter intentFilter = new IntentFilter(); intentFilter.addAction(BluetoothDevice.ACTION_ACL_CONNECTED); intentFilter.addAction(BluetoothDevice.ACTION_ACL_DISCONNECTED); @@ -264,6 +264,7 @@ public class TestService extends Service { if (BluetoothDevice.ACTION_ACL_CONNECTED.equals(action)) { //Do something if connected + //Bluetoothデバイスが接続されたときの処理 Log.d("BT", "Device connected"); @@ -271,10 +272,12 @@ public class TestService extends Service { Log.d("BT_Judge", "Registered: " + registeredId); if (deviceHardwareAddress.equals(registeredId)) { + //登録済みのデバイスだったときの処理 Log.d("BT_Judge", "登録済み"); e.putBoolean("connection_status",true); } else{ + //登録していないデバイスだったときの処理 Log.d("BT_Judge", "未登録"); e.putBoolean("connection_status",false); } @@ -282,7 +285,9 @@ public class TestService extends Service { } else if (BluetoothDevice.ACTION_ACL_DISCONNECTED.equals(action)) { //Do something if disconnected + //デバイスが切断されたときの処理 if (deviceHardwareAddress.equals(registeredId)) { + //登録済みのデバイスだったときの処理 Log.d("BT_Judge", "登録済み切断"); e.putBoolean("connection_status",false);