/** * This API is deprecated. * You should call onCreate instead of this API in Activity's onCreate(). * @param context */ @Deprecated public static void onStart(Context context) { onCreate(context); }
/** * Show the rate dialog if the criteria is satisfied. * @param context Context * @return true if shown, false otherwise. */ public static boolean showRateDialogIfNeeded(final Context context) { if (shouldShowRateDialog()) { showRateDialog(context); return true; } else { return false; } }
@Override public void onClick(View v) { RateThisApp.stopRateDialog(MainActivity.this); } });
RateThisApp.init(new RateThisApp.Config(3, 5)); RateThisApp.setCallback(new RateThisApp.Callback() { @Override public void onYesClicked() { RateThisApp.onCreate(this); RateThisApp.showRateDialogIfNeeded(this);
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); prefManager = PreferenceManager.getDefaultSharedPreferences(this); onFirstInstall(); onFirstUpdate(); handleIntent(getIntent()); if (Utils.tempBool && getIntent().getStringExtra("uri") != null) uri = Uri.parse(getIntent().getStringExtra("uri")); // Custom condition: 5 days and 5 launches RateThisApp.Config config = new RateThisApp.Config(5, 5); RateThisApp.init(config); RateThisApp.onCreate(this); RateThisApp.showRateDialogIfNeeded(this); }
RateThisApp.onCreate(this); RateThisApp.showRateDialogIfNeeded(this);
@Test public void shouldRateDialogIfNeeded_LaunchTimeIsCorrect() { Context context = RuntimeEnvironment.application.getApplicationContext(); RateThisApp.init(new RateThisApp.Config(1, 3)); RateThisApp.onStart(context); Assert.assertFalse(RateThisApp.shouldShowRateDialog()); RateThisApp.onStart(context); Assert.assertFalse(RateThisApp.shouldShowRateDialog()); RateThisApp.onStart(context); Assert.assertTrue(RateThisApp.shouldShowRateDialog()); RateThisApp.onStart(context); Assert.assertTrue(RateThisApp.shouldShowRateDialog()); }
@Override public void onClick(View v) { // Show rating dialog explicitly. RateThisApp.showRateDialog(MainActivity.this); } });
RateThisApp.onCreate(this); RateThisApp.showRateDialogIfNeeded(this);
@Override public void onClick(View v) { // Show rating dialog explicitly. RateThisApp.showRateDialog(MainActivity.this, R.style.MyAlertDialogStyle2); } });
/** * Show the rate dialog if the criteria is satisfied. * @param context Context * @param themeId Theme ID * @return true if shown, false otherwise. */ public static boolean showRateDialogIfNeeded(final Context context, int themeId) { if (shouldShowRateDialog()) { showRateDialog(context, themeId); return true; } else { return false; } }
/** * Show the rate dialog * @param context * @param themeId */ public static void showRateDialog(final Context context, int themeId) { AlertDialog.Builder builder = new AlertDialog.Builder(context, themeId); showRateDialog(context, builder); }
@Test public void stopRateDialog_IsSuccess() { Context context = RuntimeEnvironment.application.getApplicationContext(); RateThisApp.stopRateDialog(context); // check shared pref SharedPreferences sharedPreferences = RuntimeEnvironment.application.getSharedPreferences( PREF_NAME, Context.MODE_PRIVATE); Assert.assertTrue(sharedPreferences.getBoolean(KEY_OPT_OUT, false)); } }
/** * Show the rate dialog * @param context */ public static void showRateDialog(final Context context) { AlertDialog.Builder builder = new AlertDialog.Builder(context); showRateDialog(context, builder); }
RateThisApp.showRateDialog(getActivity()); return true; });