Skip to content

Commit f1a2fb4

Browse files
fixed minor issues in intentUtils
1 parent 838dcd3 commit f1a2fb4

1 file changed

Lines changed: 12 additions & 5 deletions

File tree

app/src/main/java/com/cornellappdev/transit/util/IntentUtils.kt

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ package com.cornellappdev.transit.util
33
import android.content.ActivityNotFoundException
44
import android.content.Context
55
import android.content.Intent
6+
import android.util.Log
67
import androidx.core.net.toUri
78

89
object IntentUtils {
@@ -12,13 +13,19 @@ object IntentUtils {
1213
if (launchIntent != null) {
1314
startActivity(launchIntent)
1415
} else {
16+
val playStoreIntent = Intent(Intent.ACTION_VIEW, "market://details?id=$packageName".toUri())
17+
.setPackage("com.android.vending")
18+
.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
1519
try {
16-
val playStoreIntent = Intent(Intent.ACTION_VIEW, "market://details?id=$packageName".toUri())
17-
playStoreIntent.setPackage("com.android.vending")
1820
startActivity(playStoreIntent)
19-
} catch (e2: ActivityNotFoundException) {
20-
startActivity(Intent(Intent.ACTION_VIEW, "https://play.google.com/store/apps/details?id=$packageName}".toUri()))
21-
21+
} catch (e: ActivityNotFoundException) {
22+
val webStoreIntent = Intent(Intent.ACTION_VIEW, "https://play.google.com/store/apps/details?id=$packageName".toUri())
23+
.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
24+
try {
25+
startActivity(webStoreIntent)
26+
} catch (e2: ActivityNotFoundException) {
27+
Log.e("IntentUtils","no handler for play store web URL" ,e2)
28+
}
2229
}
2330
}
2431
}

0 commit comments

Comments
 (0)