繁体   English   中英

使用导航组件在 Android 中启动 Play Store 应用

[英]Start Play Store app in Android using navigation component

我有一个带有按钮的 Android 应用程序,可以在 Play 商店中查找其他游戏。 此按钮应打开 Google Play 商店应用程序。 我有一个使用startActivity()函数和Intent标志的工作版本,正如官方文档中所述。

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

这是否可以使用导航组件来实现? 我已经尝试实现导航深度链接并设置意图操作和数据的等价物,如下所示:

<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>

但我得到一个ActivityNotFoundException: No activity found to handle Intent错误。 我究竟做错了什么? 我找不到任何进一步的文档。

最后我想通了:

  <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"
      />

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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