如何将用户吸引到Google Play进行评分?

问题描述

我在单击按钮时调用功能,以使用户在Google Play上对该应用进行评分。但这给了我错误“要查看此内容,请安装并设置Web浏览应用程序。”

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())));
    }
}

如果科特林:

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")))
    }
}