From 51fd91027d191ce728b00abc94330fd07394c2fc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=82=8D=E3=82=80=E3=81=AD=E3=81=93?= Date: Wed, 17 Jan 2024 19:49:28 +0900 Subject: [PATCH] =?UTF-8?q?ShardPreference=E3=81=AE=E3=83=81=E3=82=A7?= =?UTF-8?q?=E3=83=83=E3=82=AF=E3=81=8C=E7=95=B0=E5=B8=B8=E3=81=A0=E3=81=A3?= =?UTF-8?q?=E3=81=9F=E3=81=AE=E3=81=A7=E4=BF=AE=E6=AD=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/example/childguard/MainActivity.java | 19 +++++++------------ 1 file changed, 7 insertions(+), 12 deletions(-) diff --git a/app/src/main/java/com/example/childguard/MainActivity.java b/app/src/main/java/com/example/childguard/MainActivity.java index 94acdd5..aa8ae60 100644 --- a/app/src/main/java/com/example/childguard/MainActivity.java +++ b/app/src/main/java/com/example/childguard/MainActivity.java @@ -23,6 +23,7 @@ import android.content.Intent; import android.content.IntentFilter; import android.content.pm.PackageManager; import android.graphics.Color; +import android.graphics.Paint; import android.net.Uri; import android.os.Bundle; import android.os.Vibrator; @@ -165,12 +166,11 @@ public class MainActivity extends AppCompatActivity { String IdPref = sharedPreferences.getString("ID", null); if (IdPref == null) { Log.d("onResume", "ID not initialized."); - return; + } else { + mDocRef = FirebaseFirestore.getInstance().document("users/" + IdPref);//現在の位置を取得 + this.flg = false; + initNotification(mDocRef); } - mDocRef = FirebaseFirestore.getInstance().document("users/" + IdPref);//現在の位置を取得 - this.flg = false; - initNotification(mDocRef); - super.onResume(); } @@ -203,13 +203,8 @@ public class MainActivity extends AppCompatActivity { notifyMain(); } } else { - if (isInCar) { - E.putBoolean("car", false); - E.apply(); - } else { - E.putBoolean("car", true); - E.apply(); - } + E.putBoolean("car", !isInCar); + E.apply(); // SupportFragmentManagerが現在表示しているFragmentを取得 Fragment fragment = getSupportFragmentManager().findFragmentById(R.id.fragmentContainerView); if (fragment instanceof HomeFragment) {