public final class AppRate extends Object
AppRate Class - main class of the AndroidRate library, thread-safe and a fast singleton implementation.
Modifier and Type | Method and Description |
---|---|
AppRate |
clearAgreeShowDialog() |
AppRate |
clearSettingsParam() |
void |
dismissRateDialog()
Dismisses Rate Dialog, removing it from the screen, and
clears weak reference dialog object.
|
int |
getStoreType()
Gets the app store type from library options.
|
AppRate |
incrementEventCount(String eventName) |
boolean |
isDebug()
Checks if the library is in Debug mode.
|
boolean |
isShowingRateDialog()
Checks whether the Rate Dialog is currently showing.
|
void |
monitor()
Monitors launches of the application.
|
void |
rateNow(Activity activity)
Call this method directly if you want to send a user to rate your app right in the app
store.
|
AppRate |
set365DayPeriodMaxNumberDialogLaunchTimes(short dialogLaunchTimes)
Sets the max number of occurrences of the display of the Rate Dialog within a 365-day
period.
|
AppRate |
setAgreeShowDialog(boolean isAgree) |
AppRate |
setCancelable(boolean cancelable)
Sets whether the rating dialog is cancelable or not.
|
AppRate |
setDebug(boolean isDebug)
Debug mode.
|
AppRate |
setDialogManagerFactory(DialogManager.Factory dialogManagerFactory)
Sets DialogManager.Factory.
|
AppRate |
setEventCountValue(String eventName,
short countValue) |
AppRate |
setInstallDays(byte installDate)
Sets the minimum number of days until the Rating Dialog pops up for the first time.
|
AppRate |
setLaunchTimes(byte appLaunchTimes)
Sets the minimum number of launches until the rating dialog pops up for
the first time.
|
AppRate |
setMessage(int resourceId) |
AppRate |
setMessage(String message) |
AppRate |
setMinimumEventCount(String eventName,
short minimumCount) |
AppRate |
setOnClickButtonListener(OnClickButtonListener listener) |
AppRate |
setRemindInterval(byte remindInterval)
Sets minimal number of days until the Rating Dialog pops up for the next time after
neutral button clicked.
|
AppRate |
setRemindLaunchTimes(byte selectedAppLaunches)
Deprecated.
since 1.2.0, use
setSelectedAppLaunches(byte) with the same param instead |
AppRate |
setSelectedAppLaunches(byte selectedAppLaunches)
Selects App launches.
|
AppRate |
setShowLaterButton(boolean isShowNeutralButton)
Decides whether the Neutral button ("Remind me later") appears in the Rating Dialog or
not.
|
AppRate |
setShowNeverButton(boolean isShowNeverButton)
Decides if Never button appear in the rating dialog or not
|
AppRate |
setShowTitle(boolean isShowTitle) |
AppRate |
setStoreType(int storeType)
Sets one of the app stores defined by
StoreType.StoreWithoutApplicationId to
the Positive button. |
AppRate |
setStoreType(Intent... intents)
Sets custom action to the Positive button.
|
AppRate |
setStoreType(int storeType,
long applicationId)
Sets one of the app stores defined by
StoreType.StoreWithApplicationId to
the Positive button. |
AppRate |
setStoreType(String... uris)
Sets any other app store/stores to the Positive button.
|
AppRate |
setTextLater(int resourceId) |
AppRate |
setTextLater(String neutralText) |
AppRate |
setTextNever(int resourceId) |
AppRate |
setTextNever(String negativeText) |
AppRate |
setTextRateNow(int resourceId) |
AppRate |
setTextRateNow(String positiveText) |
AppRate |
setThemeResId(int themeResId)
Sets dialog theme.
|
AppRate |
setTitle(int resourceId) |
AppRate |
setTitle(String title) |
AppRate |
setView(View view) |
boolean |
shouldShowRateDialog()
Call this method to determine whether conditions to show the rate dialog meets or not.
|
void |
showRateDialog(Activity activity)
Call this method directly if you want to force display of the Rate Dialog.
|
static boolean |
showRateDialogIfMeetsConditions(Activity activity)
Shows the Rate Dialog when conditions are met.
|
static AppRate |
with(Context context) |
public static boolean showRateDialogIfMeetsConditions(Activity activity)
Shows the Rate Dialog when conditions are met.
Call this method at the end of your onCreate() method to determine whether to show the rate dialog or not. It will check if the conditions are met and show rate dialog if yes.
activity
- your activity, use "this" in most casespublic AppRate set365DayPeriodMaxNumberDialogLaunchTimes(short dialogLaunchTimes)
Sets the max number of occurrences of the display of the Rate Dialog within a 365-day period.
dialogLaunchTimes
- the max number of the display of the Rate Dialog within a 365-day
period, default is Short.MAX_VALUE
, Short.MAX_VALUE
means unlimited occurrencespublic AppRate setLaunchTimes(byte appLaunchTimes)
Sets the minimum number of launches until the rating dialog pops up for the first time.
appLaunchTimes
- number of launches, default is 10, 3 means app is launched 3 or
more timespublic AppRate setInstallDays(byte installDate)
Sets the minimum number of days until the Rating Dialog pops up for the first time.
installDate
- number of days, default is 10, 0 means install day, 10 means app is
launched 10 or more days later than installationpublic AppRate setRemindInterval(byte remindInterval)
Sets minimal number of days until the Rating Dialog pops up for the next time after neutral button clicked.
remindInterval
- number of days, default is 1, 1 means app is launched 1 or more days
after neutral button clickedpublic AppRate setSelectedAppLaunches(byte selectedAppLaunches)
Selects App launches.
Method sets divisor for division of app launches with a remainder. This condition is
satisfied if appLaunches % divisorAppLaunches == 0
selectedAppLaunches
- default is 1, 1 means each launch, 2 means every 2nd launch,
3 means every 3rd launch, etcpublic AppRate setRemindLaunchTimes(byte selectedAppLaunches)
setSelectedAppLaunches(byte)
with the same param
insteadSelects App launches.
Method sets divisor for division of app launches with a remainder. This condition is
satisfied if appLaunches % divisorAppLaunches == 0
selectedAppLaunches
- default is 1, 1 means each launch, 2 means every 2nd launch,
3 means every 3rd launch, etcsetSelectedAppLaunches(byte)
public AppRate setShowLaterButton(boolean isShowNeutralButton)
Decides whether the Neutral button ("Remind me later") appears in the Rating Dialog or not.
isShowNeutralButton
- default is true, true means to show the Neutral buttonpublic AppRate setShowNeverButton(boolean isShowNeverButton)
isShowNeverButton
- default is truepublic AppRate setShowTitle(boolean isShowTitle)
public AppRate clearAgreeShowDialog()
public AppRate clearSettingsParam()
public AppRate setAgreeShowDialog(boolean isAgree)
public AppRate setOnClickButtonListener(OnClickButtonListener listener)
public AppRate setTitle(int resourceId)
public AppRate setMessage(int resourceId)
public AppRate setTextRateNow(int resourceId)
public AppRate setTextLater(int resourceId)
public AppRate setTextNever(int resourceId)
public AppRate setCancelable(boolean cancelable)
cancelable
- default is falsepublic AppRate setStoreType(@StoreType.StoreWithoutApplicationId int storeType) throws IllegalArgumentException
Sets one of the app stores defined by StoreType.StoreWithoutApplicationId
to
the Positive button.
storeType
- one of the values defined by StoreType.StoreWithoutApplicationId
IllegalArgumentException
- if storeType
isn't defined by StoreType.StoreWithoutApplicationId
setStoreType(int, long)
,
setStoreType(String...)
,
setStoreType(Intent...)
public AppRate setStoreType(@StoreType.StoreWithApplicationId int storeType, long applicationId) throws IllegalArgumentException
Sets one of the app stores defined by StoreType.StoreWithApplicationId
to
the Positive button.
storeType
- one of the values defined by StoreType.StoreWithApplicationId
applicationId
- application ID in the storeType
app storeIllegalArgumentException
- if storeType
isn't defined by StoreType.StoreWithApplicationId
or by StoreType.StoreWithoutApplicationId
setStoreType(int)
,
setStoreType(String...)
,
setStoreType(Intent...)
public AppRate setStoreType(@NonNull String... uris) throws IllegalArgumentException
Sets any other app store/stores to the Positive button.
uris
- an RFC 2396-compliant URI or array of URIs to your app,
e. g. https://otherstore.com/app?id=com.yourapp
or otherstore://apps/com.yourapp
IllegalArgumentException
- if uris
equals nullsetStoreType(int)
,
setStoreType(int, long)
,
setStoreType(Intent...)
@StoreType.AnyStoreType public int getStoreType()
Gets the app store type from library options.
NOTE: this method doesn't get an app store type from user's device.
StoreType.AnyStoreType
public AppRate setStoreType(@NonNull Intent... intents) throws IllegalArgumentException
Sets custom action to the Positive button.
For example, you can open your custom RateActivity when the Positive button clicked.
intents
- any custom intent or array of intents,
first will be executed (startActivity(intents[0])
), if first fails,
second will be executed (startActivity(intents[1])
), etc.IllegalArgumentException
- if intents
equals nullsetStoreType(int)
,
setStoreType(int, long)
,
setStoreType(String...)
public AppRate setThemeResId(int themeResId)
themeResId
- theme resource ID, default is 0public AppRate setDialogManagerFactory(DialogManager.Factory dialogManagerFactory)
dialogManagerFactory
- DialogManager.Factory object, default is
DefaultDialogManager.Factory objectpublic void monitor()
Monitors launches of the application.
Call this method when the onCreate()
of the app's launcher activity is launched.
public void showRateDialog(Activity activity)
Call this method directly if you want to force display of the Rate Dialog.
Call it when some button presses on. Method also useful for testing purposes.
activity
- your activity, use "this" in most casespublic boolean isShowingRateDialog()
Checks whether the Rate Dialog is currently showing.
public void dismissRateDialog()
Dismisses Rate Dialog, removing it from the screen, and clears weak reference dialog object.
This method can be invoked safely from any thread.
public void rateNow(Activity activity)
Call this method directly if you want to send a user to rate your app right in the app store.
activity
- your activity, use "this" in most casespublic boolean shouldShowRateDialog()
public boolean isDebug()
Checks if the library is in Debug mode. For development only!
public AppRate setDebug(boolean isDebug)
Debug mode. For development only!
Setting the library to Debug mode ensures that the Rate Dialog will be shown each time the app is launched.
isDebug
- default is false, true ensures that the Rate Dialog will be shown each time
the app is launched