我已经打开谷歌播放商店使用以下代码

Intent i = new Intent(android.content.Intent.ACTION_VIEW);
i.setData(Uri.parse("https://play.google.com/store/apps/details?id=my packagename "));
startActivity(i);.

但它向我显示了一个完整的操作视图,以选择选项(浏览器/播放商店)。我需要直接在Play Store打开应用程序。


当前回答

如果你想从你的应用程序打开谷歌播放商店,那么直接使用这个命令:market://details?gotohome=com。yourAppName,它将打开你的应用程序的谷歌播放商店页面。

网站:http://play.google.com/store/apps/details?id= 应用:市场:/ /细节?id =

显示特定发行商的所有应用

网站:http://play.google.com/store/search?q=pub 应用:市场:/ /搜索?q =酒吧:

搜索使用标题或描述上的查询的应用程序

网站:http://play.google.com/store/search?q= 应用:市场:/ /搜索?q =

参考:https://tricklio.com/market-details-gotohome-1/

其他回答

测试。这应该可以正常工作。

val context = LocalContext.current
val onOpenPlayStore: () -> Unit = {
    try {
        LOG.d(tag, "onOpenPlayStore ${context.packageName}")
        val intent = Intent(Intent.ACTION_VIEW, Uri.parse("market://details?id=${context.packageName}"))
        startActivity(context, intent, null)
    } catch (e: ActivityNotFoundException) {
        var intent = Intent(Intent.ACTION_VIEW, Uri.parse("https://play.google.com/store/apps/details?id=${context.packageName}"))
        startActivity(context, intent, null)
    }
}

试试这个

Intent intent = new Intent(Intent.ACTION_VIEW);
intent.setData(Uri.parse("market://details?id=com.example.android"));
startActivity(intent);

你可以:

final Uri marketUri = Uri.parse("market://details?id=" + packageName);
startActivity(new Intent(Intent.ACTION_VIEW, marketUri));

在这里获取参考资料:

你也可以尝试这个问题公认答案中描述的方法: 无法确定谷歌播放商店是否安装在Android设备上

这个问题的一些答案已经过时了。

对我来说(在2020年)有效的方法是明确地告诉玩家跳过选择器并直接打开游戏商店应用,如下所示:

“如果你想从Android应用程序链接到你的产品,创建一个 打开URL的意图。当你配置这个意图时,通过 “com.android。自动售货”到Intent.setPackage()中,以便用户看到您的 应用程序的详细信息在谷歌Play Store应用程序,而不是一个选择器。”

这是我用来指导用户在谷歌Play中查看包含包名称com.google.android.apps.maps的应用程序的Kotlin代码:

val intent = Intent(Intent.ACTION_VIEW).apply {
               data = Uri.parse("http://play.google.com/store/apps/details?id=com.google.android.apps.maps")
               setPackage("com.android.vending")
            }
            startActivity(intent)

我希望这能帮助到一些人!

科特林:

扩展:

fun Activity.openAppInGooglePlay(){

val appId = BuildConfig.APPLICATION_ID
try {
    this.startActivity(Intent(Intent.ACTION_VIEW, Uri.parse("market://details?id=$appId")))
} catch (anfe: ActivityNotFoundException) {
    this.startActivity(
        Intent(
            Intent.ACTION_VIEW,
            Uri.parse("https://play.google.com/store/apps/details?id=$appId")
        )
    )
}}

方法:

    fun openAppInGooglePlay(activity:Activity){

        val appId = BuildConfig.APPLICATION_ID
        try {
            activity.startActivity(Intent(Intent.ACTION_VIEW, Uri.parse("market://details?id=$appId")))
        } catch (anfe: ActivityNotFoundException) {
            activity.startActivity(
                Intent(
                    Intent.ACTION_VIEW,
                    Uri.parse("https://play.google.com/store/apps/details?id=$appId")
                )
            )
        }
    }