简体   繁体   中英

Start Play Store app in Android using navigation component

I have an Android application with a button to find other games on Play Store. This button should open the Google Play Store application. I have a working version which uses the startActivity() function and Intent flags, just as mentioned in this official doc .

Intent intent = new Intent(Intent.ACTION_VIEW)
                    .setData(Uri.parse("https://play.google.com/store/apps?someapp")
                    .setPackage("com.android.vending");
this.startActivity(intent)

Is this possible to achieve using Navigation Components instead? I have tried implementing a Navigation Deep Link and to set the equivalent of intent actions and data like so:

<activity
    android:id="@+id/playstore_activity">
    <deeplink
         app:uri="https://play.google.com/store/apps?someapp"
         app:action="android.intent.action.ACTION_VIEW"
         app:targetPackage="com.android.vending"/>
</activity>

But I am getting an ActivityNotFoundException: No activity found to handle Intent error. What am I doing wrong? I am unable to find any further documentation of this.

I figured it out in the end:

  <activity
      android:id="@+id/playstore"
      android:label="Travel to PlayStore"
      app:action="android.intent.action.VIEW"
      app:data="@string/playstore_path"
      app:targetPackage="com.android.vending"
      />

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM