diff --git a/app/src/main/java/com/gmail/afonsotrepa/pocketgopher/gopherclient/HtmlPage.java b/app/src/main/java/com/gmail/afonsotrepa/pocketgopher/gopherclient/HtmlPage.java index dab7a44..a15368a 100644 --- a/app/src/main/java/com/gmail/afonsotrepa/pocketgopher/gopherclient/HtmlPage.java +++ b/app/src/main/java/com/gmail/afonsotrepa/pocketgopher/gopherclient/HtmlPage.java @@ -118,11 +118,17 @@ public void run() { try { + // attempt file connect/download (possible IOEXception) Connection conn = new Connection(page.server, page.port); conn.getBinary(page.selector, file); + // attempt view intent (possible ActivityNotFoundException) + Intent intent = new Intent(Intent.ACTION_VIEW); + intent.addCategory(Intent.CATEGORY_BROWSABLE); + intent.setData(Uri.fromFile(file)); + context.startActivity(intent); } - catch (final IOException e) + catch (final IOException | ActivityNotFoundException e) { e.printStackTrace(); //inform the user of the error @@ -139,11 +145,6 @@ public void run() } }); } - - Intent intent = new Intent(Intent.ACTION_VIEW); - intent.addCategory(Intent.CATEGORY_BROWSABLE); - intent.setData(Uri.fromFile(file)); - context.startActivity(intent); } }).start(); } @@ -155,4 +156,4 @@ public void run() Toast.makeText(context, e.getMessage(), Toast.LENGTH_LONG).show(); } } -} \ No newline at end of file +}