Nav*_*een 92 android google-play
我正在开发一个Android应用程序.其中一切正常.我的应用已准备好发布.但我需要再实现一个功能.我需要显示一个包含的弹出窗口
Rate It 和 Remind me later
如果有任何用户对市场中的应用进行评级,则弹出窗口不会消失.我在谷歌搜索过,发现了一个链接.有了这个,我明白它不可能知道.所以我需要一个建议.
以前有人遇到过这种情况吗?如果是这样,是否有任何解决方案或替代方案?
Rag*_*ood 169
我在一段时间内实现了这一点.不可能知道用户是否对应用程序进行了评级,以防止评级成为一种货币(一些开发人员可能会添加一个选项,如"评价此应用程序并在应用程序中免费获取").
我编写的类提供了三个按钮,并配置对话框,使其仅在应用程序启动后显示n(如果用户之前使用过它,用户有更高的评级应用程序的机会.大多数不太可能甚至不知道它在第一次运行时做了什么):
public class AppRater {
private final static String APP_TITLE = "App Name";// App Name
private final static String APP_PNAME = "com.example.name";// Package Name
private final static int DAYS_UNTIL_PROMPT = 3;//Min number of days
private final static int LAUNCHES_UNTIL_PROMPT = 3;//Min number of launches
public static void app_launched(Context mContext) {
SharedPreferences prefs = mContext.getSharedPreferences("apprater", 0);
if (prefs.getBoolean("dontshowagain", false)) { return ; }
SharedPreferences.Editor editor = prefs.edit();
// Increment launch counter
long launch_count = prefs.getLong("launch_count", 0) + 1;
editor.putLong("launch_count", launch_count);
// Get date of first launch
Long date_firstLaunch = prefs.getLong("date_firstlaunch", 0);
if (date_firstLaunch == 0) {
date_firstLaunch = System.currentTimeMillis();
editor.putLong("date_firstlaunch", date_firstLaunch);
}
// Wait at least n days before opening
if (launch_count >= LAUNCHES_UNTIL_PROMPT) {
if (System.currentTimeMillis() >= date_firstLaunch +
(DAYS_UNTIL_PROMPT * 24 * 60 * 60 * 1000)) {
showRateDialog(mContext, editor);
}
}
editor.commit();
}
public static void showRateDialog(final Context mContext, final SharedPreferences.Editor editor) {
final Dialog dialog = new Dialog(mContext);
dialog.setTitle("Rate " + APP_TITLE);
LinearLayout ll = new LinearLayout(mContext);
ll.setOrientation(LinearLayout.VERTICAL);
TextView tv = new TextView(mContext);
tv.setText("If you enjoy using " + APP_TITLE + ", please take a moment to rate it. Thanks for your support!");
tv.setWidth(240);
tv.setPadding(4, 0, 4, 10);
ll.addView(tv);
Button b1 = new Button(mContext);
b1.setText("Rate " + APP_TITLE);
b1.setOnClickListener(new OnClickListener() {
public void onClick(View v) {
mContext.startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("market://details?id=" + APP_PNAME)));
dialog.dismiss();
}
});
ll.addView(b1);
Button b2 = new Button(mContext);
b2.setText("Remind me later");
b2.setOnClickListener(new OnClickListener() {
public void onClick(View v) {
dialog.dismiss();
}
});
ll.addView(b2);
Button b3 = new Button(mContext);
b3.setText("No, thanks");
b3.setOnClickListener(new OnClickListener() {
public void onClick(View v) {
if (editor != null) {
editor.putBoolean("dontshowagain", true);
editor.commit();
}
dialog.dismiss();
}
});
ll.addView(b3);
dialog.setContentView(ll);
dialog.show();
}
}
Run Code Online (Sandbox Code Playgroud)
集成类就像添加:
AppRater.app_launched(this);
Run Code Online (Sandbox Code Playgroud)
致你的活动.它只需要添加到整个应用程序中的一个Activity.
sas*_*oar 33
我使用这个:https://github.com/kskkbys/Android-RateThisApp - 很好,有点不引人注意的行为.

mix*_*xel 16
我使用DialogFragment:
public class RateItDialogFragment extends DialogFragment {
private static final int LAUNCHES_UNTIL_PROMPT = 10;
private static final int DAYS_UNTIL_PROMPT = 3;
private static final int MILLIS_UNTIL_PROMPT = DAYS_UNTIL_PROMPT * 24 * 60 * 60 * 1000;
private static final String PREF_NAME = "APP_RATER";
private static final String LAST_PROMPT = "LAST_PROMPT";
private static final String LAUNCHES = "LAUNCHES";
private static final String DISABLED = "DISABLED";
public static void show(Context context, FragmentManager fragmentManager) {
boolean shouldShow = false;
SharedPreferences sharedPreferences = getSharedPreferences(context);
SharedPreferences.Editor editor = sharedPreferences.edit();
long currentTime = System.currentTimeMillis();
long lastPromptTime = sharedPreferences.getLong(LAST_PROMPT, 0);
if (lastPromptTime == 0) {
lastPromptTime = currentTime;
editor.putLong(LAST_PROMPT, lastPromptTime);
}
if (!sharedPreferences.getBoolean(DISABLED, false)) {
int launches = sharedPreferences.getInt(LAUNCHES, 0) + 1;
if (launches > LAUNCHES_UNTIL_PROMPT) {
if (currentTime > lastPromptTime + MILLIS_UNTIL_PROMPT) {
shouldShow = true;
}
}
editor.putInt(LAUNCHES, launches);
}
if (shouldShow) {
editor.putInt(LAUNCHES, 0).putLong(LAST_PROMPT, System.currentTimeMillis()).commit();
new RateItDialogFragment().show(fragmentManager, null);
} else {
editor.commit();
}
}
private static SharedPreferences getSharedPreferences(Context context) {
return context.getSharedPreferences(PREF_NAME, 0);
}
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
return new AlertDialog.Builder(getActivity())
.setTitle(R.string.rate_title)
.setMessage(R.string.rate_message)
.setPositiveButton(R.string.rate_positive, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("market://details?id=" + getActivity().getPackageName())));
getSharedPreferences(getActivity()).edit().putBoolean(DISABLED, true).commit();
dismiss();
}
})
.setNeutralButton(R.string.rate_remind_later, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
dismiss();
}
})
.setNegativeButton(R.string.rate_never, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
getSharedPreferences(getActivity()).edit().putBoolean(DISABLED, true).commit();
dismiss();
}
}).create();
}
}
Run Code Online (Sandbox Code Playgroud)
然后在onCreate()主FragmentActivity中使用它:
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
...
RateItDialogFragment.show(this, getFragmentManager());
}
Run Code Online (Sandbox Code Playgroud)
iDe*_*ode 12
首先,在您的build.gradle(app)文件中,添加以下依赖项(此处为完整设置)
dependencies {
// This dependency is downloaded from the Google’s Maven repository.
// So, make sure you also include that repository in your project's build.gradle file.
implementation 'com.google.android.play:core:1.8.0'
}
Run Code Online (Sandbox Code Playgroud)
将此方法添加到您的Activity:
void askRatings() {
ReviewManager manager = ReviewManagerFactory.create(this);
Task<ReviewInfo> request = manager.requestReviewFlow();
request.addOnCompleteListener(task -> {
if (task.isSuccessful()) {
// We can get the ReviewInfo object
ReviewInfo reviewInfo = task.getResult();
Task<Void> flow = manager.launchReviewFlow(this, reviewInfo);
flow.addOnCompleteListener(task2 -> {
// The flow has finished. The API does not indicate whether the user
// reviewed or not, or even whether the review dialog was shown. Thus, no
// matter the result, we continue our app flow.
});
} else {
// There was some problem, continue regardless of the result.
}
});
}
Run Code Online (Sandbox Code Playgroud)
像任何其他方法一样调用它:
askRatings();
Run Code Online (Sandbox Code Playgroud)
Kotlin 代码可以在这里找到
我认为你要做的事情可能适得其反.
让人们轻松评价应用程序通常是一个好主意,因为大多数人都喜欢这样做因为他们喜欢这个应用程序.据传,评级数量会影响您的市场评级(尽管我看不到这方面的证据).通过唠叨屏幕对用户进行评级可能会导致人们通过留下糟糕的评级来清除唠叨.
添加直接评价应用程序的功能导致我的免费版本的数字评级略有下降,并且我的付费应用程序略有增加.对于免费的应用程序,我的4星评级增加超过我的5星评级,因为那些认为我的应用程序很好但不是很好的人开始评价它.变化约为-0.2.对于付费,变化约为+0.1.我应该从免费版本中删除它,除了我喜欢收到很多评论.
我将我的评级按钮放入设置(首选项)屏幕,它不会影响正常操作.它仍然将我的评级率提高了4或5倍.我毫不怀疑,如果我试图唠叨我的用户进行评级,我会让很多用户给我评价不好作为抗议.
AndroidRate是一个库,可通过提示用户在使用几天后对其进行评分来帮助您推广android应用。
模块摇篮:
dependencies {
implementation 'com.vorlonsoft:androidrate:1.0.8'
}
Run Code Online (Sandbox Code Playgroud)
MainActivity.java:
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
AppRate.with(this)
.setStoreType(StoreType.GOOGLEPLAY) //default is GOOGLEPLAY (Google Play), other options are
// AMAZON (Amazon Appstore) and
// SAMSUNG (Samsung Galaxy Apps)
.setInstallDays((byte) 0) // default 10, 0 means install day
.setLaunchTimes((byte) 3) // default 10
.setRemindInterval((byte) 2) // default 1
.setRemindLaunchTimes((byte) 2) // default 1 (each launch)
.setShowLaterButton(true) // default true
.setDebug(false) // default false
//Java 8+: .setOnClickButtonListener(which -> Log.d(MainActivity.class.getName(), Byte.toString(which)))
.setOnClickButtonListener(new OnClickButtonListener() { // callback listener.
@Override
public void onClickButton(byte which) {
Log.d(MainActivity.class.getName(), Byte.toString(which));
}
})
.monitor();
if (AppRate.with(this).getStoreType() == StoreType.GOOGLEPLAY) {
//Check that Google Play is available
if (GoogleApiAvailability.getInstance().isGooglePlayServicesAvailable(this) != ConnectionResult.SERVICE_MISSING) {
// Show a dialog if meets conditions
AppRate.showRateDialogIfMeetsConditions(this);
}
} else {
// Show a dialog if meets conditions
AppRate.showRateDialogIfMeetsConditions(this);
}
}
Run Code Online (Sandbox Code Playgroud)
显示速率对话框的默认条件如下:
AppRate#setInstallDays(byte)。AppRate#setLaunchTimes(byte)。AppRate#setRemindInterval(byte)。AppRate#setRemindLaunchTimes(byte)。通过更改。setShowLaterButton(boolean)。DialogInterface.OnClickListener#onClick将传递到的参数中onClickButton。AppRate#setDebug(boolean)将确保每次启动应用程序时都会显示评级请求。此功能仅用于开发!。您可以添加其他可选要求以显示对话框。每个需求都可以作为唯一字符串添加/引用。您可以为每个此类事件设置最小计数(例如,“ action_performed” 3次,“ button_clicked” 5次,等等)
AppRate.with(this).setMinimumEventCount(String, short);
AppRate.with(this).incrementEventCount(String);
AppRate.with(this).setEventCountValue(String, short);
Run Code Online (Sandbox Code Playgroud)
要再次显示对话框时,请致电AppRate#clearAgreeShowDialog()。
AppRate.with(this).clearAgreeShowDialog();
Run Code Online (Sandbox Code Playgroud)
打电话AppRate#showRateDialog(Activity)。
AppRate.with(this).showRateDialog(this);
Run Code Online (Sandbox Code Playgroud)
打电话AppRate#setView(View)。
LayoutInflater inflater = (LayoutInflater)this.getSystemService(LAYOUT_INFLATER_SERVICE);
View view = inflater.inflate(R.layout.custom_dialog, (ViewGroup)findViewById(R.id.layout_root));
AppRate.with(this).setView(view).monitor();
Run Code Online (Sandbox Code Playgroud)
您可以使用特定主题来扩大对话框。
AppRate.with(this).setThemeResId(int);
Run Code Online (Sandbox Code Playgroud)
如果要使用自己的对话框标签,请在应用程序上覆盖字符串xml资源。
<resources>
<string name="rate_dialog_title">Rate this app</string>
<string name="rate_dialog_message">If you enjoy playing this app, would you mind taking a moment to rate it? It won\'t take more than a minute. Thanks for your support!</string>
<string name="rate_dialog_ok">Rate It Now</string>
<string name="rate_dialog_cancel">Remind Me Later</string>
<string name="rate_dialog_no">No, Thanks</string>
</resources>
Run Code Online (Sandbox Code Playgroud)
if (GoogleApiAvailability.getInstance().isGooglePlayServicesAvailable(this) != ConnectionResult.SERVICE_MISSING) {
}
Run Code Online (Sandbox Code Playgroud)
小智 5
对于应用内评论,请确保实施以下内容:
implementation 'com.google.android.play:core:1.8.0'
Run Code Online (Sandbox Code Playgroud)
创建时
public void RateApp(Context mContext) {
try {
ReviewManager manager = ReviewManagerFactory.create(mContext);
manager.requestReviewFlow().addOnCompleteListener(new OnCompleteListener<ReviewInfo>() {
@Override
public void onComplete(@NonNull Task<ReviewInfo> task) {
if(task.isSuccessful()){
ReviewInfo reviewInfo = task.getResult();
manager.launchReviewFlow((Activity) mContext, reviewInfo).addOnFailureListener(new OnFailureListener() {
@Override
public void onFailure(Exception e) {
Toast.makeText(mContext, "Rating Failed", Toast.LENGTH_SHORT).show();
}
}).addOnCompleteListener(new OnCompleteListener<Void>() {
@Override
public void onComplete(@NonNull Task<Void> task) {
Toast.makeText(mContext, "Review Completed, Thank You!", Toast.LENGTH_SHORT).show();
}
});
}
}
}).addOnFailureListener(new OnFailureListener() {
@Override
public void onFailure(Exception e) {
Toast.makeText(mContext, "In-App Request Failed", Toast.LENGTH_SHORT).show();
}
});
} catch (ActivityNotFoundException e) {
e.printStackTrace();
}
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
85782 次 |
| 最近记录: |