Android - Link to app will not open in Google Play

Try directly this if link is originated from an app for Android to handle:

market://details?id=<package_name>

Note: There's no domain and host.


I'm using the code below and it is working fine with my phone and emulator.

For the phone with Google Play app, it will automatically open the app. For the emulator (without Google Play app), it will automatically open the browser.

try { 
  Intent intent = new Intent(Intent.ACTION_VIEW);
  intent.setData(Uri.parse("market://details?id=com.example"));
  startActivity(intent);
} catch (Exception e) { //google play app is not installed
  Intent intent = new Intent(Intent.ACTION_VIEW);
  intent.setData(Uri.parse("https://play.google.com/store/apps/details?id=com.example"));
  startActivity(intent);
}