如何将用户发送到 Google 播放以评价应用程序?

How to send a user to Google play to rate the app?

我在单击按钮时调用此函数,让用户在 Google 播放时对应用进行评分。但它给我错误“要查看此内容,请安装并设置网络浏览应用程序。”

private void rateMe() {
        try {
            startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("market://details?id=$packageName")));
        } catch (ActivityNotFoundException e) {
            startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("http://play.google.com/store/apps/details?id=$packageName")));
        }
    }

不知道你用的是Java还是Kotlin

如果Java:

 private void rateMe() {
    try {
        startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("market://details?id=" + getPackageName())));
    } catch (ActivityNotFoundException e) {
        startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("http://play.google.com/store/apps/details?id=" + getPackageName())));
    }
}

如果Kotlin:

private fun rateMe() {
    try {
        startActivity(Intent(Intent.ACTION_VIEW, Uri.parse("market://details?id=$packageName")))
    } catch (e: ActivityNotFoundException) {
        startActivity(Intent(Intent.ACTION_VIEW, Uri.parse("http://play.google.com/store/apps/details?id=$packageName")))
    }
}