gil*_*h14 4 android review rate google-play
有很多Q&A的用户如何能够在应用程序内评分我的应用程序,但我需要只是一个直接链接到审查\率我的应用程序通过邮件发送用户,而不是我的应用程序页面中的市场,因为在那里,他需要依序按一下[审查然后登录,然后写评论,这是令人筋疲力尽,而不是用户友好.
TNX
为了不用恼人的表单打扰用户,您可以添加一个菜单项,让用户通过Google Play中的应用程序站点对应用程序进行评级.用户单击此选项后,不应再次显示此内容(即使用户未在最后对应用程序进行评级).在我看来,这个解决方案非常友好.
添加这样的菜单项(在res\menu [menu] .xml中):
<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>
Run Code Online (Sandbox Code Playgroud)
在您的主要活动中添加以下内容,以便在用户对您的应用进行评分后隐藏该选项:
@Override
public boolean onPrepareOptionsMenu(Menu menu)
{
MenuItem register = menu.findItem(R.id.MenuRateApp);
if(fApp.isRated()) {
register.setVisible(false);
}
return true;
}
Run Code Online (Sandbox Code Playgroud)
fApp.isRated()
如果用户已对应用程序进行了评级,则更改for表示保留布尔值的方法或变量(使用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);
}
Run Code Online (Sandbox Code Playgroud)
希望这个解决方案符合您的要求.
注意:部分代码是从这个站点借来的:
http://martin.cubeactive.com/android-how-to-create-a-rank-this-app-button/
例:
归档时间: |
|
查看次数: |
6307 次 |
最近记录: |