In my app I have a menu item that I want to open up the user\'s preferred media player, only interested in audio. Ideally the first time the user chooses this item it would
Intent resolveIntent = new Intent(Intent.ACTION_VIEW);
if (type.startsWith("audio/*")) {
Uri uri = Uri.withAppendedPath(
MediaStore.Audio.Media.INTERNAL_CONTENT_URI, "1");
resolveIntent.setDataAndType(uri, type);
} else if (type.startsWith("video/*")) {
Uri uri = Uri.withAppendedPath(
MediaStore.Video.Media.INTERNAL_CONTENT_URI, "1");
resolveIntent.setDataAndType(uri, type);
} else if (type.startsWith("application/pdf")) {
resolveIntent.setType(type);
}
List pkgAppsList = mContext.getPackageManager().queryIntentActivities(resolveIntent, PackageManager.GET_RESOLVED_FILTER);
Here is my solution, If you want get a list of "video/" or "audio/" APPs, you should use "setDataAndType"; But if you want to get a list of "text/*" or "pdf" APPs, you can use "setType".