AndroidRateKotlin is a Kotlin library to help you promote your android app by prompting users to rate the app after using it for a few days. Original project AndroidRate (The MIT License (MIT)) was developed by Vorlonsoft LLC.
You can download from Maven Central.
${latest.version} is
Gradle
dependencies {
implementation 'com.vorlonsoft:android-rate:{latest.version}'
}
AndroidRateKotlin provides methods to configure its behavior.
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_main)
val storeType = StoreType.GOOGLEPLAY // options: GOOGLEPLAY or AMAZON
AppRate.with(this)
?.setStoreType(storeType) //default is GOOGLEPLAY, other option is AMAZON
?.setInstallDays(0) // default 10, 0 means install day
?.setLaunchTimes(3) // default 10
?.setRemindInterval(2) // default 1
?.setRemindLaunchTimes(2) // default 1 (each launch)
?.setShowLaterButton(true) // default true
?.setDebug(false) // default false
?.monitor()
if (storeType == 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)
}
}
The default conditions to show rate dialog is as below:
AppRate#setInstallDays(Int)
.AppRate#setLaunchTimes(Int)
.AppRate#setRemindInterval(Int)
.AppRate#setRemindLaunchTimes(Int)
.setShowLaterButton(Boolean)
.AppRate#setDebug(Boolean)
will ensure that the rating request is shown each time the app is launched. This feature is only for development!.You can add additional optional requirements for showing dialog. Each requirement can be added/referenced as a unique string. You can set a minimum count for each such event (for e.g. "action_performed" 3 times, "button_clicked" 5 times, etc.)
AppRate.with(this)?.setMinimumEventCount(String, Long)
AppRate.with(this)?.incrementEventCount(String)
AppRate.with(this)?.setEventCountValue(String, Long)
When you want to show the dialog again, call AppRate#clearAgreeShowDialog()
.
AppRate.with(this)?.clearAgreeShowDialog()
call AppRate#showRateDialog(Activity)
.
AppRate.with(this)?.showRateDialog(this)
call AppRate#setView(View)
.
internal var inflater = this.getSystemService(LAYOUT_INFLATER_SERVICE) as LayoutInflater
internal var view = inflater.inflate(R.layout.custom_dialog, findViewById(R.id.layout_root) as ViewGroup)
AppRate.with(this)?.setView(view)?.monitor()
You can use a specific theme to inflate the dialog.
AppRate.with(this)?.setThemeResId(Integer)
If you want to use your own dialog labels, override string xml resources on your application.
<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>
if (GoogleApiAvailability.getInstance().isGooglePlayServicesAvailable(this) != ConnectionResult.SERVICE_MISSING) {
}
AndroidRateKotlin currently supports the following languages:
AndroidRateKotlin supports API level 9 and up.
Please try to move the sample.
git checkout -b my-new-feature
)git commit -am 'Added some feature'
)git push origin my-new-feature
)