diff options
author | Michael Weghorn <m.weghorn@posteo.de> | 2022-04-14 09:34:28 +0200 |
---|---|---|
committer | Michael Weghorn <m.weghorn@posteo.de> | 2022-04-19 08:41:13 +0200 |
commit | 0d622b07d78fe61eacc3a32bdfc973808d7b9829 (patch) | |
tree | 4c6cd79ce9a539c67dd1d118ce0178fdd8b6a995 | |
parent | 752c1b4e078594edb724240a9ecfa3b7efa766ff (diff) |
android: Use proper Intent to open doc for API level < 19
`Intent.ACTION_OPEN_DOCUMENT` was introduced in API level 19,
therefore `Intent.ACTION_GET_CONTENT` is supposed to be used
for older Android versions.
The previous attempt at doing so didn't work, since no
`ActivityNotFoundException` is thrown when trying
to set the action to `Intent.ACTION_OPEN_DOCUMENT` on
older Android versions.
Fix that by using a proper version check instead.
Change-Id: Ie06fa3f39e3042b4b7161a3c937bf655eb658abd
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/133025
Tested-by: Jenkins
Reviewed-by: Michael Weghorn <m.weghorn@posteo.de>
(cherry picked from commit 003e2873e4463974e59e1f909f9250cde743851f)
-rw-r--r-- | android/source/src/java/org/libreoffice/ui/LibreOfficeUIActivity.java | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/android/source/src/java/org/libreoffice/ui/LibreOfficeUIActivity.java b/android/source/src/java/org/libreoffice/ui/LibreOfficeUIActivity.java index c18b784e581b..f2e366c90ed3 100644 --- a/android/source/src/java/org/libreoffice/ui/LibreOfficeUIActivity.java +++ b/android/source/src/java/org/libreoffice/ui/LibreOfficeUIActivity.java @@ -258,9 +258,10 @@ public class LibreOfficeUIActivity extends AppCompatActivity implements Settings private void showSystemFilePickerAndOpenFile() { Intent intent = new Intent(); - try { + if (Build.VERSION.SDK_INT >= 19) { intent.setAction(Intent.ACTION_OPEN_DOCUMENT); - } catch (ActivityNotFoundException exception) { + } + else { // Intent.ACTION_OPEN_DOCUMENT added in API level 19, but minSdkVersion is currently 16 intent.setAction(Intent.ACTION_GET_CONTENT); } |