From 003e2873e4463974e59e1f909f9250cde743851f Mon Sep 17 00:00:00 2001 From: Michael Weghorn Date: Thu, 14 Apr 2022 09:34:28 +0200 Subject: 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 --- .../source/src/java/org/libreoffice/ui/LibreOfficeUIActivity.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'android') 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); } -- cgit