This commit is contained in:
ろむねこ 2024-07-11 15:48:06 +09:00
parent 1231748f76
commit e19ee4d623
No known key found for this signature in database
GPG Key ID: FA1F39A1BA37D168

View File

@ -236,13 +236,8 @@ public class TestService extends Service {
} }
private final BroadcastReceiver receiver = new BroadcastReceiver() { private final BroadcastReceiver receiver = new BroadcastReceiver() {
//PreferenceManager.getDefaultSharedPreferences("myPreferences",Context.MODE_PRIVATE);
@Override @Override
public void onReceive(Context context, Intent intent) { public void onReceive(Context context, Intent intent) {
// 処理対象か確認 ---------------------------------------- // 処理対象か確認 ----------------------------------------
BluetoothDevice device = intent.getParcelableExtra(BluetoothDevice.EXTRA_DEVICE); BluetoothDevice device = intent.getParcelableExtra(BluetoothDevice.EXTRA_DEVICE);
if (device == null) { if (device == null) {
@ -264,7 +259,6 @@ public class TestService extends Service {
return; return;
} }
// ----------------------------------------------------- // -----------------------------------------------------
String action = intent.getAction(); // may need to chain this to a recognizing function String action = intent.getAction(); // may need to chain this to a recognizing function
boolean isInCar = getSharedPreferences("Bluetooth_situation", MODE_PRIVATE).getBoolean("isInCarPref", false); boolean isInCar = getSharedPreferences("Bluetooth_situation", MODE_PRIVATE).getBoolean("isInCarPref", false);
if (BluetoothDevice.ACTION_ACL_DISCONNECTED.equals(action) && !isInCar) { if (BluetoothDevice.ACTION_ACL_DISCONNECTED.equals(action) && !isInCar) {
@ -273,7 +267,6 @@ public class TestService extends Service {
// 5分経過した時点でも車に乗っていない場合 // 5分経過した時点でも車に乗っていない場合
Notification(context, BLUETOOTH_NOTIFICATION); Notification(context, BLUETOOTH_NOTIFICATION);
}; };
handler.postDelayed(notificationRunnable, 5 * 60 * 1000); // 5分をミリ秒に変換 handler.postDelayed(notificationRunnable, 5 * 60 * 1000); // 5分をミリ秒に変換
} else if (BluetoothDevice.ACTION_ACL_CONNECTED.equals(action)) { } else if (BluetoothDevice.ACTION_ACL_CONNECTED.equals(action)) {
// 再接続された場合通知をキャンセルする // 再接続された場合通知をキャンセルする