Specifically, I\'m trying to figure out if there is an application to handle the market intent, but I\'d like a general case solution.
I know if you do something lik
This is a practical example from CommonWare's answer.
String strURL="market://details?id="+thePackage;
Intent the_intent = new Intent(Intent.ACTION_VIEW, Uri.parse(strURL));
the_intent.addFlags( Intent.FLAG_ACTIVITY_NEW_TASK );
Log.v(TAG,""+_context.getPackageManager().queryIntentActivities(the_intent,Intent.FLAG_ACTIVITY_NEW_TASK));
if (_context.getPackageManager().queryIntentActivities(the_intent,0).size()==0)
{
String strUrl="https://play.google.com/store/search?c=apps&q="+thePackage;
the_intent = new Intent(Intent.ACTION_VIEW, Uri.parse(strUrl));
the_intent.addFlags( Intent.FLAG_ACTIVITY_NEW_TASK );
}
Use PackageManager and queryIntentActivities() or resolveActivity(). The former will return a List of things that match an Intent to be used with startActivity(). The latter will return null for no matches or an Intent which is the "best match" (which could be the chooser activity if there is more than one match).