android/source/src/java/org/libreoffice/ui/LibreOfficeUIActivity.java |    5 
+++--
 1 file changed, 3 insertions(+), 2 deletions(-)

New commits:
commit 003e2873e4463974e59e1f909f9250cde743851f
Author:     Michael Weghorn <m.wegh...@posteo.de>
AuthorDate: Thu Apr 14 09:34:28 2022 +0200
Commit:     Michael Weghorn <m.wegh...@posteo.de>
CommitDate: Thu Apr 14 20:40:23 2022 +0200

    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.wegh...@posteo.de>

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);
         }

Reply via email to