From b89c642a343836dcfb7f56c1b4d7b53a381825d6 Mon Sep 17 00:00:00 2001 From: Ko SeongChan Date: Thu, 20 Jun 2024 15:30:50 +0900 Subject: [PATCH] =?UTF-8?q?=EC=A0=80=EC=9E=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/example/sharenote/HomeFragment.kt | 1 + .../sharenote/MyFirebaseMessagingService.kt | 3 ++- .../com/example/sharenote/SplashActivity.kt | 19 +++++++++++++------ 3 files changed, 16 insertions(+), 7 deletions(-) diff --git a/android/app/src/main/java/com/example/sharenote/HomeFragment.kt b/android/app/src/main/java/com/example/sharenote/HomeFragment.kt index ecfc6bfb..d8a234f1 100644 --- a/android/app/src/main/java/com/example/sharenote/HomeFragment.kt +++ b/android/app/src/main/java/com/example/sharenote/HomeFragment.kt @@ -277,6 +277,7 @@ class HomeFragment : Fragment() { val settingLayoutView = popupView.findViewById(R.id.logoutLayout) settingLayoutView.setOnClickListener { auth.signOut() + SharedPreferencesUtil.saveLoggedInStatus(requireContext(), false) val loginIntent = Intent(requireContext(), LoginActivity::class.java) startActivity(loginIntent) requireActivity().finish() diff --git a/android/app/src/main/java/com/example/sharenote/MyFirebaseMessagingService.kt b/android/app/src/main/java/com/example/sharenote/MyFirebaseMessagingService.kt index 9c507830..9237821b 100644 --- a/android/app/src/main/java/com/example/sharenote/MyFirebaseMessagingService.kt +++ b/android/app/src/main/java/com/example/sharenote/MyFirebaseMessagingService.kt @@ -35,7 +35,8 @@ class MyFirebaseMessagingService : FirebaseMessagingService() { // 알림 클릭 시 실행할 액티비티 설정 val intent = Intent(this, QuizActivity::class.java) intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP) - val pendingIntent = PendingIntent.getActivity(this, 0, intent, PendingIntent.FLAG_ONE_SHOT or PendingIntent.FLAG_UPDATE_CURRENT) + intent.putExtra("fromNotification", true) + val pendingIntent = PendingIntent.getActivity(this, 0, intent, PendingIntent.FLAG_ONE_SHOT or PendingIntent.FLAG_IMMUTABLE) // 알림 생성 val notificationBuilder = NotificationCompat.Builder(this, "default") diff --git a/android/app/src/main/java/com/example/sharenote/SplashActivity.kt b/android/app/src/main/java/com/example/sharenote/SplashActivity.kt index 858f1d14..0fee3596 100644 --- a/android/app/src/main/java/com/example/sharenote/SplashActivity.kt +++ b/android/app/src/main/java/com/example/sharenote/SplashActivity.kt @@ -8,7 +8,6 @@ import androidx.appcompat.app.AppCompatActivity class SplashActivity : AppCompatActivity() { - override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) setContentView(R.layout.activity_splash) @@ -17,11 +16,19 @@ class SplashActivity : AppCompatActivity() { supportActionBar?.hide() val handler = Handler(Looper.getMainLooper()) - handler.postDelayed(Runnable { - Intent(this, LoginActivity::class.java).apply { - startActivity(this) - finish() + handler.postDelayed({ + val targetActivity = if (intent.getBooleanExtra("fromNotification", false)) { + QuizActivity::class.java + } else { + if (SharedPreferencesUtil.isLoggedIn(this)) { + MainActivity::class.java + } else { + LoginActivity::class.java + } } + val nextIntent = Intent(this, targetActivity) + startActivity(nextIntent) + finish() }, 3000) // 3초 후(3000) 스플래시 화면을 닫습니다 } -} \ No newline at end of file +}