Hi All, I have an app that downloads a pdf from a server and tries to open it with an itent:
Intent intent = new Intent(); intent.setAction(android.content.Intent.ACTION_VIEW); File file = new File(filepath+filename); intent.setDataAndType(Uri.fromFile(file), "application/pdf"); try { startActivity(intent); } catch (ActivityNotFoundException e) { final Exception ef = e; txt2.post(new Runnable() { public void run() { txt2.setText(" "+ef); } }); } Everything works great if any applications are installed on the device that will open a pdf. But, if no apps are installed, this part of the code just segfaults (my catching of the exception apparently does not work). Here is the logcat output I/ActivityManager( 61): Starting activity: Intent { act=android.intent.action.VIEW dat=file:///sdcard/arXiv/tmp.pdf typ=application/pdf } W/dalvikvm( 322): threadid=7: thread exiting with uncaught exception (group=0x4001d800) E/AndroidRuntime( 322): FATAL EXCEPTION: Thread-9 E/AndroidRuntime( 322): java.lang.NullPointerException E/AndroidRuntime( 322): at com.commonsware.android.arXiv.singleitemwindow $1.run(singleitemwindow.java:243) W/ActivityManager( 61): Force finishing activity com.commonsware.android.arXiv/.singleitemwindow So, my question is can I somehow determine if any app is available for application/pdf mimetype ahead of time. Or, can I prevent the code from dying here and tell the user to install a pdf reader app? -Jack -- 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