LoginSignup
10
9

More than 5 years have passed since last update.

GooglePlayStoreアプリを開くスニペット

Posted at

GooglePlayStoreアプリがあったらアプリを開き、なかったらWebで開く実装です。

private void openPlayStore(Context context) {
    final String appPackageName = context.getPackageName();
    try {
        context.startActivity(new Intent(Intent.ACTION_VIEW,
            Uri.parse("market://details?id=" + appPackageName)));
    } catch (android.content.ActivityNotFoundException anfe) {
        context.startActivity(new Intent(Intent.ACTION_VIEW,
            Uri.parse("http://play.google.com/store/apps/details?id=" + appPackageName)));
    }
}
10
9
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
10
9