Skip to content

Commit

Permalink
Fixed because it was crashing when launched from NFC without a networ…
Browse files Browse the repository at this point in the history
…k connection
  • Loading branch information
[email protected] committed Sep 16, 2023
1 parent 3ed1da1 commit 09767cc
Showing 1 changed file with 19 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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() {

Expand All @@ -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()
Expand Down

0 comments on commit 09767cc

Please sign in to comment.