Skip to content

Instantly share code, notes, and snippets.

@tkuenneth
Created October 15, 2019 13:54
Show Gist options
  • Save tkuenneth/651e5ed1032b9d2aed5afa95dbc73b16 to your computer and use it in GitHub Desktop.
Save tkuenneth/651e5ed1032b9d2aed5afa95dbc73b16 to your computer and use it in GitHub Desktop.
How to launch the Play Store
package com.thomaskuenneth.playground
import android.content.ActivityNotFoundException
import android.content.Intent
import android.os.Bundle
import android.util.Log
import androidx.appcompat.app.AppCompatActivity
class LaunchGooglePlayDemo : AppCompatActivity() {
private val tag = LaunchGooglePlayDemo::class.simpleName
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
launchGooglePlay()
}
private fun launchGooglePlay() {
val intent = Intent.makeMainSelectorActivity(
Intent.ACTION_MAIN,
Intent.CATEGORY_APP_MARKET
)
try {
startActivity(intent)
} catch (e: ActivityNotFoundException) {
Log.e(tag, "launchGooglePlay()", e)
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment