From 569035d6f61b76a2826cdec126ebf6b50ecaba38 Mon Sep 17 00:00:00 2001 From: Ethan Chen Date: Wed, 27 Jan 2016 13:31:13 -0800 Subject: Snap: Don't crash when hardcoded gallery intent fails * startActivity may also throw IllegalArgumentException in addition to ActivityNotFoundException when the component can't be found. Change-Id: Ia3124591c625f4c249f3c6f76a226e8178df6e9d --- src/com/android/camera/CameraActivity.java | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-) diff --git a/src/com/android/camera/CameraActivity.java b/src/com/android/camera/CameraActivity.java index 8e0c144c1..e6e1ea4b1 100644 --- a/src/com/android/camera/CameraActivity.java +++ b/src/com/android/camera/CameraActivity.java @@ -599,14 +599,22 @@ public class CameraActivity extends Activity intent.putExtra(KEY_TOTAL_NUMBER, (adapter.getTotalNumber() -1)); startActivity(intent); } catch (ActivityNotFoundException ex) { - try { - Log.w(TAG, "Gallery not found"); - Intent intent = new Intent(Intent.ACTION_VIEW, uri); - startActivity(intent); - intent.putExtra(KEY_FROM_SNAPCAM, true); - } catch (ActivityNotFoundException e) { - Log.w(TAG, "No Activity could be found to open image or video"); - } + gotoViewPhoto(uri); + } catch (IllegalArgumentException ex) { + gotoViewPhoto(uri); + } + } + + private void gotoViewPhoto(Uri uri) { + try { + Log.w(TAG, "Gallery not found"); + Intent intent = new Intent(Intent.ACTION_VIEW, uri); + startActivity(intent); + intent.putExtra(KEY_FROM_SNAPCAM, true); + } catch (ActivityNotFoundException e) { + Log.w(TAG, "No Activity could be found to open image or video"); + } catch (IllegalArgumentException e) { + Log.w(TAG, "No Activity could be found to open image or video"); } } -- cgit v1.2.3