@@ -3,6 +3,7 @@ package com.cornellappdev.transit.util
33import android.content.ActivityNotFoundException
44import android.content.Context
55import android.content.Intent
6+ import android.util.Log
67import androidx.core.net.toUri
78
89object 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