java - 如何在Android 10天内调用一次Play API的应用内评论?
问题描述
我实现了 Play Core Library 的应用内评论,但当我第一次打开应用时会弹出评论。
有没有办法只有在应用程序使用 10 天后才打开那个弹出框?
我已经使用此代码来实现它:
ReviewManager manager;
ReviewInfo reviewInfo;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.abc);
manager = ReviewManagerFactory.create(this);
Task<ReviewInfo> request = manager.requestReviewFlow();
request.addOnCompleteListener(task -> {
if (task.isSuccessful()) {
// We can get the ReviewInfo object
reviewInfo = task.getResult();
openReview();
}
});
}
public void openReview(){
if(reviewInfo != null){
Task<Void> flow = manager.launchReviewFlow(this, reviewInfo);
flow.addOnCompleteListener(task -> {
// 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.
});
}
解决方案
我会这样做:
- 首次打开应用程序时,记录日期/时间并将其保存在
SharedPreferences
- 每次用户打开应用程序时执行当前日期/时间 - 首次打开应用程序的日期/时间。
- 如果此值超过 10 天,则显示 IAP Review 对话框。然后您将重置存储在
SharedPreferences
推荐阅读
- r - 如何在互联网连接不稳定的情况下使用 rtweet 包中的 get_followers 函数
- python - 乌龟窗口没有打开turtle.mainloop
- docker - Authenticator 不支持请求
- apache-zeppelin - 为 Zeppelin 安装解释器
- sql - 检查最新记录是否超过 1 小时
- python - Python - 查找列表列表中没有重复内部项目的最大子集
- elixir - asdf 的 .tool-versions 文件应该进入 .gitignore 吗?
- java - log4j2 xml 无法识别程序参数
- reactjs - 如何使用中止控制器或可取消的承诺取消多个 setState 调用
- c++ - Visual Studio 找不到 SDK(10.0.17763.0) 的已安装版本的解决方案