I want to show the review after the user open my app for the second time. Can anyone share the code for this.
Thanks in advaNCE.........
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();
} else {
// There was some problem, log or handle the error code.
@ReviewErrorCode int reviewErrorCode = ((TaskException) task.getException()).getErrorCode();
}
});
..............
CodePudding user response:
Okay, so you need to store the user open app count in the database or etc, I suggest you use SharedPrefrence or DataStore, which are both of them based on the key-value collection. Well in the code:
public class MainActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main2);
SharedPreferences preferences = getSharedPreferences("app_setting", Activity.MODE_PRIVATE);
int openCount = preferences.getInt("app_open_count", 0);
if (openCount >= 2) {
// show the review manager dialog
} else {
preferences.edit().putInt("app_open_count", openCount).apply();
}
}
}
Also, you can increase the app_open_count in SplashActivity or wherever you want. I did it at MainActivity because MainActivity is my application's first activity the user has seen. this is not complex code and you can modify that.