添加评级功能一个Android应用程序,因为我已经在Playstore上发布了我的应用程序现在我想将此应用程序功能添加到该应用程序,但我不知道该怎么做。如果有人有任何想法,请告诉我。 三江源
答案 0 :(得分:0)
您无法直接为自己的应用评分。您需要将用户重定向到Play商店并要求他们评价5星。
//To check if the playsytore app is installed or not
private boolean MyStartActivity(Intent aIntent) {
try
{
startActivity(aIntent);
return true;
}
catch (ActivityNotFoundException e)
{
return false;
}
}
//On click event for rate this app button
public void btnRateAppOnClick(View v) {
Intent intent = new Intent(Intent.ACTION_VIEW);
//Try Google play
intent.setData(Uri.parse("market://details?id=cs.nizam.funeralrites"));
if (!MyStartActivity(intent)) {
//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=cs.nizam.funeralrites"));
if (!MyStartActivity(intent)) {
//Well if this also fails, we have run out of options, inform the user.
Snackbar.make(v, "Could not open Android market, please install the market app.", Snackbar.LENGTH_LONG)
.setAction("Action", null).show();
}
}
}
答案 1 :(得分:0)
Google没有提供API来评估Play商店的应用程序。但是,可以通过在Play商店中将用户导航到您的应用并要求用户在那里进行评分来实现此目的。这可以通过调用以下简单方法来实现。你只需要调用这个函数并休息,它就会自行完成。
public static void rateThisApplication(Context context)
{
Uri uri = Uri.parse("market://details?id=" + context.getPackageName());
Intent goToMarket = new Intent(Intent.ACTION_VIEW, uri);
// To count with Play market backstack, After pressing back button,
// to taken back to our application, we need to add following flags to intent.
goToMarket.addFlags(Intent.FLAG_ACTIVITY_NO_HISTORY | Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET |
Intent.FLAG_ACTIVITY_MULTIPLE_TASK);
try
{
context.startActivity(goToMarket);
}
catch (ActivityNotFoundException e)
{
context.startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("http://play.google.com/store/apps/details?id=" + context.getPackageName())));
}
finally
{
uri = null;
goToMarket = null;
}
}