diff options
author | Ethan Chen <intervigil@gmail.com> | 2016-01-27 13:31:13 -0800 |
---|---|---|
committer | Arne Coucheron <arco68@gmail.com> | 2018-01-26 01:03:12 +0100 |
commit | 9977fa8c7a4ff4761457ea73cb4183e3e4ebdc24 (patch) | |
tree | b35ada77c9a73f8843ac80cf24b79cab25446b2e | |
parent | 211633db4133b43526108b658632a142ac4755dd (diff) | |
download | android_packages_apps_Snap-9977fa8c7a4ff4761457ea73cb4183e3e4ebdc24.tar.gz android_packages_apps_Snap-9977fa8c7a4ff4761457ea73cb4183e3e4ebdc24.tar.bz2 android_packages_apps_Snap-9977fa8c7a4ff4761457ea73cb4183e3e4ebdc24.zip |
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
-rw-r--r-- | src/com/android/camera/CameraActivity.java | 24 |
1 files changed, 16 insertions, 8 deletions
diff --git a/src/com/android/camera/CameraActivity.java b/src/com/android/camera/CameraActivity.java index a7ddfe7c7..b040f36a7 100644 --- a/src/com/android/camera/CameraActivity.java +++ b/src/com/android/camera/CameraActivity.java @@ -615,14 +615,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); - intent.putExtra(KEY_FROM_SNAPCAM, true); - startActivity(intent); - } 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); + intent.putExtra(KEY_FROM_SNAPCAM, true); + startActivity(intent); + } 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"); } } |