start Implicit intent and allow them to download if that external activity is not available.
Intent intent =new Intent(Intent.ACTION_DIAL, Uri.parse(“tel:555-2368”));
// Check if an Activity exists to perform this action.
PackageManager pm = getPackageManager();
ComponentName cn = intent.resolveActivity(pm);
if (cn == null)
{
// If there is no Activity available to perform the action
// Check to see if the Google Play Store is available.
Uri marketUri = Uri.parse(“market://search?q=pname:com.myapp.packagename”);
Intent marketIntent = new Intent(Intent.ACTION_VIEW).setData(marketUri);
// If the Google Play Store is available, use it to download an application
// capable of performing the required action. Otherwise, log an
// error.
if (marketIntent.resolveActivity(pm) != null)
startActivity(marketIntent);
else Log.d(TAG, “Market client not available.”);
}
else
startActivity(intent);
Comments
Post a Comment