Forgive me if this is a topic that has already been discussed, but I've searched for hours and can't seem to find the answer I'm looking for. I'm trying to cut my teeth on Android programming with a simple file manager app and currently have most all functions working, but I can't seem to open a selected file with the appropriate app. Here is my current code:
/ **********************************************************************************************************/ String extension = MimeTypeMap.getFileExtensionFromUrl((String)label.getText()); String mimeType = MimeTypeMap.getSingleton().getMimeTypeFromExtension(extension); if (mimeType != null && MimeTypeMap.getSingleton().hasMimeType(mimeType)) { try { File fileToOpen = new File(filePath + "/" + label.getText()); Intent i = new Intent(); i.setAction(android.content.Intent.ACTION_VIEW); i.setDataAndType(Uri.fromFile(fileToOpen), mimeType); startActivity(i); } catch (Exception e) { Toast.makeText(this, "Could Not Open File!", Toast.LENGTH_SHORT).show(); } } else { Toast.makeText(this, "Unknown Mime Type", Toast.LENGTH_SHORT).show(); } / **********************************************************************************************************/ The strange thing is that I get some rather interesting results with this code. On my handset, it doesn't seem to want to open doc files at all, but will open the one xls file I have without a problem in Docs2Go. Also, when throwing about 10 pdf files at it, it will open 2 of them with no problem but claims "Unknown Mime Type" on the other 8. Theoretically, this code should find the extension on the file, then figure out the appropriate MIME type from the extension, then call the activity handing over the MIME type as an argument, but theory doesn't seem to be enough to get me through this one. Any suggestions you guys can make, or tutorials you can point me at would be greatly appreciated. Thanks! -Bryan -- You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en