1 回答

TA貢獻(xiàn)1877條經(jīng)驗 獲得超1個贊
您可以使用這個解決方案 -
Intent intent = getPackageManager().getLaunchIntentForPackage("com.example.myapp");
if(intent.resolveActivity(context.getPackageManager()) != null){? //Open app if installed
? ? startActivity(intent);
}else{//Send to play store to download or instant app solution
try {
? ? startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("market://details?id=com.example.myapp")));
} catch (ActivityNotFoundException anfe) {
? ? startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("https://play.google.com/store/apps/details?id=com.example.myapp")));
}
}
添加回答
舉報