As I can see in Android documentation when trying to build implicit intents when sending the user to another app. These are the two approaches to avoid ActivityNotFoundException.
First one :
Intent mapIntent = new Intent(Intent.ACTION_VIEW, location);
PackageManager packageManager = getPackageManager();
List<ResolveInfo> activities = packageManager.queryIntentActivities(intent,
PackageManager.MATCH_DEFAULT_ONLY);
boolean isIntentSafe = activities.size() > 0;
Second one :
Intent chooser = Intent.createChooser(intent, title);
if (intent.resolveActivity(getPackageManager()) != null) {
}
Now my doubt is whats the differnece and which one should i use ?
queryIntentActivities
returns non empty list thenresolveActivity()
should not returnnull
for the sameIntent
? – Thermobarograph