有很多关于如何在应用程序中让用户评价我的应用程序的问答,但我只需要一条直接的链接通过邮件发送给用户以评价我的应用程序,而不是到市场上的应用程序页面,因为那里需要点击评价,然后登录,然后编写评论,这很繁琐而且不友好。谢谢。
<menu xmlns:android="http://schemas.android.com/apk/res/android" >
(other options...)
<item android:id="@+id/MenuRateApp" android:title="@string/menu_Rate_app"
android:icon="@drawable/ic_menu_star"></item>
</menu>
@Override
public boolean onPrepareOptionsMenu(Menu menu)
{
MenuItem register = menu.findItem(R.id.MenuRateApp);
if(fApp.isRated()) {
register.setVisible(false);
}
return true;
}
将fApp.isRated()
更改为一个方法或变量,该方法或变量保留一个布尔值,指示用户是否已经评价了应用程序(使用sharedPreferences机制编写和读取此值)。
重定向用户到您在Google Play中的应用程序网站的代码可能如下所示:
private boolean MyStartActivity(Intent aIntent) {
try {
startActivity(aIntent);
return true;
} catch (ActivityNotFoundException e) {
return false;
}
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
(other options code...)
if (item.getItemId() == R.id.MenuRateApp) {
//Try Google play
Intent intent = new Intent(Intent.ACTION_VIEW);
intent.setData(Uri.parse("market://details?id="+getPackageName()));
if (MyStartActivity(intent) == false) {
//Market (Google play) app seems not installed, let's try to open a webbrowser
intent.setData(Uri.parse("https://play.google.com/store/apps/details?id="+getPackageName()));
if (MyStartActivity(intent) == false) {
//Well if this also fails, we have run out of options, inform the user.
Toast.makeText(this, this.getString(R.string.error_no_google_play), Toast.LENGTH_LONG).show();
}
}
//Do not disturb again (even if the user did not rated the app in the end)
fApp.setRated(true);
}
return super.onOptionsItemSelected(item);
}
http://martin.cubeactive.com/android-how-to-create-a-rank-this-app-button/
示例:根据我之前发布的一个类似问题,我期望得到的答案是:
https://play.google.com/store/apps/details?id= + your.package.name