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

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打开应用程序。


当前回答

人们,不要忘记你实际上可以从中得到更多的东西。我指的是UTM跟踪。https://developers.google.com/analytics/devguides/collection/android/v4/campaigns

public static final String MODULE_ICON_PACK_FREE = "com.example.iconpack_free";
public static final String APP_STORE_URI =
        "market://details?id=%s&referrer=utm_source=%s&utm_medium=app&utm_campaign=plugin";
public static final String APP_STORE_GENERIC_URI =
        "https://play.google.com/store/apps/details?id=%s&referrer=utm_source=%s&utm_medium=app&utm_campaign=plugin";

try {
    startActivity(new Intent(
        Intent.ACTION_VIEW,
        Uri.parse(String.format(Locale.US,
            APP_STORE_URI,
            MODULE_ICON_PACK_FREE,
            getPackageName()))).addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP));
} catch (android.content.ActivityNotFoundException anfe) {
    startActivity(new Intent(
        Intent.ACTION_VIEW,
        Uri.parse(String.format(Locale.US,
            APP_STORE_GENERIC_URI,
            MODULE_ICON_PACK_FREE,
            getPackageName()))).addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP));
}

其他回答

很晚了官方文件来了。代码描述如下

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

当你配置这个意图时,传递“com.android.”自动售卖”到Intent.setPackage()中,以便用户在谷歌Play Store应用程序中看到应用程序的详细信息,而不是选择器。 在芬兰湾的科特林

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

如果您已经使用谷歌Play instant发布了即时应用,您可以通过以下方式启动应用:

Intent intent = new Intent(Intent.ACTION_VIEW);
Uri.Builder uriBuilder = Uri.parse("https://play.google.com/store/apps/details")
    .buildUpon()
    .appendQueryParameter("id", "com.example.android")
    .appendQueryParameter("launch", "true");

// Optional parameters, such as referrer, are passed onto the launched
// instant app. You can retrieve these parameters using
// Activity.getIntent().getData().
uriBuilder.appendQueryParameter("referrer", "exampleCampaignId");

intent.setData(uriBuilder.build());
intent.setPackage("com.android.vending");
startActivity(intent);

KOTLIN的

val uriBuilder = Uri.parse("https://play.google.com/store/apps/details")
        .buildUpon()
        .appendQueryParameter("id", "com.example.android")
        .appendQueryParameter("launch", "true")

// Optional parameters, such as referrer, are passed onto the launched
// instant app. You can retrieve these parameters using Activity.intent.data.
uriBuilder.appendQueryParameter("referrer", "exampleCampaignId")

val intent = Intent(Intent.ACTION_VIEW).apply {
    data = uriBuilder.build()
    setPackage("com.android.vending")
}
startActivity(intent)

如果你想从你的应用程序打开谷歌播放商店,那么直接使用这个命令: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/

试试这个

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

而Eric的答案是正确的,Berťák的代码也可以工作。我认为这两者结合起来更优雅。

try {
    Intent appStoreIntent = new Intent(Intent.ACTION_VIEW, Uri.parse("market://details?id=" + appPackageName));
    appStoreIntent.setPackage("com.android.vending");

    startActivity(appStoreIntent);
} catch (android.content.ActivityNotFoundException exception) {
    startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("https://play.google.com/store/apps/details?id=" + appPackageName)));
}

通过使用setPackage,您可以强制设备使用Play Store。如果没有安装Play Store,异常将被捕获。

你可以:

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

在这里获取参考资料:

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