As asked by a user on Reddit, how do you parse market:// links if Google Play isn’t installed on the device? Or how do you handle links to different markets?
As a general rule I try using the market link first, but surround it in a try/catch and look for an ActivityNotFoundException exception (this is thrown if Google Play is not installed). At that point I just create a Uri to the weblink instead and send the user there.
try
{
Uri uri = Uri.parse("market://details?id=com.cryptopone.pricecompare");
Intent intent = new Intent(Intent.ACTION_VIEW, uri);
startActivity(intent);
}
catch(ActivityNotFoundException iox)
{
Uri uri = Uri.parse("http://play.google.com/store/apps/details?id=com.cryptopone.pricecompare");
Intent intent = new Intent(Intent.ACTION_VIEW, uri);
startActivity(intent);
}
If I publish the app on several markets, I use a conditional statement prior to this try/catch to determine what market the links are applicable for. With Amazon I just spawn a web link to the app, but maybe you want to handle other markets differently.