From 09767cc8c785c9b219c8f242cf38c1f6d61eb587 Mon Sep 17 00:00:00 2001 From: "kwmt27@gmail.com" Date: Sat, 16 Sep 2023 13:39:28 +0900 Subject: [PATCH] Fixed because it was crashing when launched from NFC without a network connection --- .../ResolveDynamicLinksActivity.kt | 22 ++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) diff --git a/app-android/src/main/java/io/github/droidkaigi/confsched2023/ResolveDynamicLinksActivity.kt b/app-android/src/main/java/io/github/droidkaigi/confsched2023/ResolveDynamicLinksActivity.kt index e60f71937..837994eaa 100644 --- a/app-android/src/main/java/io/github/droidkaigi/confsched2023/ResolveDynamicLinksActivity.kt +++ b/app-android/src/main/java/io/github/droidkaigi/confsched2023/ResolveDynamicLinksActivity.kt @@ -6,8 +6,15 @@ import android.content.Intent.FLAG_ACTIVITY_NEW_TASK import android.content.Intent.FLAG_ACTIVITY_REQUIRE_DEFAULT import android.net.Uri import android.os.Bundle +import android.util.Log +import android.widget.Toast import androidx.activity.ComponentActivity import com.google.firebase.dynamiclinks.FirebaseDynamicLinks +import io.github.droidkaigi.confsched2023.designsystem.strings.Lang +import io.github.droidkaigi.confsched2023.model.Lang.ENGLISH +import io.github.droidkaigi.confsched2023.model.Lang.JAPANESE +import io.github.droidkaigi.confsched2023.model.Lang.MIXED +import io.github.droidkaigi.confsched2023.model.defaultLang class ResolveDynamicLinksActivity : ComponentActivity() { @@ -17,9 +24,18 @@ class ResolveDynamicLinksActivity : ComponentActivity() { FirebaseDynamicLinks.getInstance() .getDynamicLink(intent) .addOnSuccessListener(this) { pendingDynamicLinkData -> - val deepLink = pendingDynamicLinkData.link - - handleDeepLink(deepLink) + if (pendingDynamicLinkData != null) { + val deepLink = pendingDynamicLinkData.link + handleDeepLink(deepLink) + } else { + val message = when(defaultLang()) { + MIXED -> "Please connect to the network/ネットワークに接続してください" + JAPANESE -> "ネットワークに接続してください" + ENGLISH -> "Please connect to the network" + } + Toast.makeText(this, message, Toast.LENGTH_SHORT).show() + finishAndRemoveTask() + } } .addOnFailureListener { finishAndRemoveTask()