Skip to content

Instantly share code, notes, and snippets.

@VarunBarad
Created February 15, 2018 06:42
Show Gist options
  • Select an option

  • Save VarunBarad/17158545c87737b65e426e10795f7f68 to your computer and use it in GitHub Desktop.

Select an option

Save VarunBarad/17158545c87737b65e426e10795f7f68 to your computer and use it in GitHub Desktop.

Revisions

  1. Varun Barad created this gist Feb 15, 2018.
    14 changes: 14 additions & 0 deletions MainActivity.kt
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,14 @@
    // Kotlin
    public fun rateApp(rateMeButton: View): Unit {
    val packageName = this.packageName
    val playStoreAppUri = "market://details?id=$packageName"
    val playStoreSiteUri = "https://play.google.com/store/apps/details?id=$packageName"

    try {
    val playStoreAppIntent = Intent(Intent.ACTION_VIEW, Uri.parse(playStoreAppUri))
    startActivity(playStoreAppIntent)
    } catch (e: ActivityNotFoundException) {
    val playStoreBrowserIntent = Intent(Intent.ACTION_VIEW, Uri.parse(playStoreSiteUri))
    startActivity(playStoreBrowserIntent)
    }
    }