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

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


当前回答

现成的解决方案:

public class GoogleServicesUtils {

    public static void openAppInGooglePlay(Context context) {
        final String appPackageName = context.getPackageName();
        try {
            context.startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("market://details?id=" + appPackageName)));
        } catch (android.content.ActivityNotFoundException e) { // if there is no Google Play on device
            context.startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("https://play.google.com/store/apps/details?id=" + appPackageName)));
        }
    }

}

根据Eric的回答。

其他回答

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

您可以检查谷歌Play Store应用程序是否已安装,如果是这种情况,您可以使用“market://”协议。

final String my_package_name = "........."  // <- HERE YOUR PACKAGE NAME!!
String url = "";

try {
    //Check whether Google Play store is installed or not:
    this.getPackageManager().getPackageInfo("com.android.vending", 0);

    url = "market://details?id=" + my_package_name;
} catch ( final Exception e ) {
    url = "https://play.google.com/store/apps/details?id=" + my_package_name;
}


//Open the app page in Google Play store:
final Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(url));
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET);
startActivity(intent);

科特林

fun openAppInPlayStore(appPackageName: String) {
    try {
        startActivity(Intent(Intent.ACTION_VIEW, Uri.parse("market://details?id=$appPackageName")))
    } catch (exception: android.content.ActivityNotFoundException) {
        startActivity(Intent(Intent.ACTION_VIEW, Uri.parse("https://play.google.com/store/apps/details?id=$appPackageName")))
    }
}

你可以:

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

在这里获取参考资料:

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

如果你想单独打开谷歌Play(或任何其他应用程序),以上所有答案都可以在同一个应用程序的新视图中打开谷歌Play:

Intent launchIntent = getPackageManager().getLaunchIntentForPackage("com.android.vending");

// package name and activity
ComponentName comp = new ComponentName("com.android.vending",
                                       "com.google.android.finsky.activities.LaunchUrlHandlerActivity"); 
launchIntent.setComponent(comp);

// sample to open facebook app
launchIntent.setData(Uri.parse("market://details?id=com.facebook.katana"));
startActivity(launchIntent);

重要的部分是实际上打开谷歌播放或任何其他应用程序独立。

我看到的大多数答案都使用了其他答案的方法,这不是我需要的,希望这能帮助到别人。

的问候。