TestServiceの全体的なリファクタリング #28
| 
						 | 
					@ -265,13 +265,8 @@ public class TestService extends Service {
 | 
				
			||||||
            SharedPreferences pref = getSharedPreferences("Bluetooth_situation", MODE_PRIVATE);
 | 
					            SharedPreferences pref = getSharedPreferences("Bluetooth_situation", MODE_PRIVATE);
 | 
				
			||||||
            SharedPreferences.Editor e = pref.edit();
 | 
					            SharedPreferences.Editor e = pref.edit();
 | 
				
			||||||
            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 = pref.getBoolean("isInCarPref", false);
 | 
					            boolean isInCar = pref.getBoolean("isInCarPref", false);
 | 
				
			||||||
            if (BluetoothDevice.ACTION_ACL_DISCONNECTED.equals(action) && !isInCar) {//bluetoothが切断されたときに乗車状態のとき
 | 
					            if (BluetoothDevice.ACTION_ACL_DISCONNECTED.equals(action) && !isInCar) {//bluetoothが切断されたときに乗車状態のとき
 | 
				
			||||||
 | 
					 | 
				
			||||||
                //Do something if disconnected
 | 
					 | 
				
			||||||
                //デバイスが切断されたときの処理
 | 
					 | 
				
			||||||
                if (deviceHardwareAddress.equals(registeredId)) {
 | 
					 | 
				
			||||||
                // 5分待機する
 | 
					                // 5分待機する
 | 
				
			||||||
                Handler handler = new Handler();
 | 
					                Handler handler = new Handler();
 | 
				
			||||||
                handler.postDelayed(new Runnable() {
 | 
					                handler.postDelayed(new Runnable() {
 | 
				
			||||||
| 
						 | 
					@ -284,9 +279,6 @@ public class TestService extends Service {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                }, 5 * 60 * 1000); // 5分をミリ秒に変換
 | 
					                }, 5 * 60 * 1000); // 5分をミリ秒に変換
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
            } else {
 | 
					 | 
				
			||||||
                Log.d("BT", "Device disconnected");
 | 
					 | 
				
			||||||
            }
 | 
					 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
    };
 | 
					    };
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in New Issue
	
	Block a user