DEV Community

Mayank
Mayank

Posted on

Answer: how to open android application if installed and go to android market if not install

inside onclick

@Override
public void onClick(View view){
  try{
    startActivity(getPackageManager().getLaunchIntentForPackage("applicationId"));
  } catch (PackageManager.NameNotFoundException e) {
    startActivity(new Intent(Intent.ACTION_VIEW).setData(Uri.parse("https://play.google.com/store/apps/details?id=" + "applicationId")));
 }
}

Top comments (0)