アプリ内からパッケージを指定して、Playストアアプリを起動させる方法です。
public void execPlayApp(Context context, String targetPackage) {
Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse("market://details?id=" + targetPackage));
try {
context.startActivity(intent);
} catch (Exception e) {
e.printStackTrace();
}
}
さらに、起動したいアプリがインストールされているかをチェックすれば、アプリがインストールされていない時は、Playストアに飛ばすこともできますね。
public boolean isInstall() {
try {
// パッケージ名を指定してインストール状況をチェック
PackageManager packageManager = this.getPackageManager();
ApplicationInfo applicationInfo = packageManager.getApplicationInfo(TARGET_PACKAGE, PackageManager.GET_META_DATA);
if (applicationInfo != null) {
return true;
}
} catch (NameNotFoundException exception) {
return false;
}
return false;
}