HomeFragmentがResumeされたときにローカルの最新を読み込むように

This commit is contained in:
ろむねこ 2024-01-19 12:53:01 +09:00
parent e84b21288f
commit 9d431bd297
No known key found for this signature in database
GPG Key ID: FA1F39A1BA37D168

View File

@ -1,5 +1,6 @@
package com.example.childguard;
import android.content.SharedPreferences;
import android.os.Bundle;
import android.util.Log;
import android.view.LayoutInflater;
@ -76,6 +77,12 @@ public class HomeFragment extends Fragment implements OnEventListener{
public void onResume() {
super.onResume();
Log.d("HomeFragment", "onResume: called");
this.updateUiState(getIsInCarLocal());
}
private boolean getIsInCarLocal() {
SharedPreferences pref = requireActivity().getSharedPreferences("app_situation", requireActivity().MODE_PRIVATE);
return pref.getBoolean("isInCar", false);
}
//画面遷移メソッド