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-14 20:40:23 +0200 |
commit | 003e2873e4463974e59e1f909f9250cde743851f (patch) | |
tree | d1dac1ea172ad7eafb2d669ce397a87d587817f1 /android/source | |
parent | f869807175f1fc49328465473aa8e90b6f1876ff (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>
Diffstat (limited to 'android/source')
-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); } |