I have this method so far, but it appeared as if something was missing
for example, I have a /sdcard/sound.3ga file that returns false (for example, there is no activity that can handle this type of file). But when I open it from the file manager, it opens with a media player without a problem
I think this intention is not complete, and I need something else to make sure that the variable handlerExists will be false ONLY if there is no activity that can handle this intention.
PackageManager pm = getPackageManager(); Intent intent = new Intent(android.content.Intent.ACTION_VIEW); String extension = android.webkit.MimeTypeMap.getFileExtensionFromUrl(Uri.fromFile(new File(uriString)).toString()); String mimetype = android.webkit.MimeTypeMap.getSingleton().getMimeTypeFromExtension(extension); intent.setDataAndType(Uri.fromFile(new File(uriString)),mimetype); boolean handlerExists = intent.resolveActivity(pm) != null;
android mime-types android-intent file-type intentfilter
Lukap Mar 14 '13 at 11:07 2013-03-14 11:07
source share