Created
October 15, 2019 13:54
-
-
Save tkuenneth/651e5ed1032b9d2aed5afa95dbc73b16 to your computer and use it in GitHub Desktop.
How to launch the Play Store
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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