Fork me on GitHub

Friday, March 1, 2013

Prompt user to rate your Android app

To make your app is frequently searched, user rating is important. Prompt engaged user with a dialog that asking a (favorable) vote is a common technique. Although it is some kind of exploit, I think that it is not so dirty, because nobody hurts by doing this. I have googled about it and found a code snippet here. However, that code is too long whereas it does a simple thing. I rewrite it using Scaloid

onCreate {
  val prefs = Preferences()
  val ec = prefs.executionCount(0)
  prefs.executionCount = ec + 1
  if (ec % 20 == 19 && !prefs.wontRate(false)) {
    new AlertDialogBuilder(null, "Please take a moment to rate it.") {
      positiveButton("Rate it", {
        openUri("market://details?id=com.soundcorset.client.android")
        prefs.wontRate = true
      })
      neutralButton("Remind me later")
      negativeButton("No thanks", {
        prefs.wontRate = true
      })
    }.show()
  }
}

Comparing with the original code, this is really simple, isn't it?

No comments:

Post a Comment