Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Mobile and Embedded
  4. Android 11 QDir::mkDir() does not always work

Android 11 QDir::mkDir() does not always work

Scheduled Pinned Locked Moved Solved Mobile and Embedded
android 11qdir
11 Posts 5 Posters 4.1k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • K Offline
    K Offline
    koahnig
    wrote on 31 May 2021, 15:05 last edited by
    #1

    My app generates a folder on "/storage/emulated/0/Android/data" following the common rules of "<country code>.<company>.<app name>". Upto including Android 10 this worked without an issue.

    QDir cur = QDir::current();
    cur.mkdir ("zz.yyyyyyyy.xxx");
    

    With Android 11 this does not create the folder reliably anymore. Sometimes it worked but on other occations it does not.

    Basically the app shall create a data folder accessible for other applications in order to transfer the output anywhere.

    I guess this is due to the new rules of storage management for Android 11.

    Any suggestions how to get around this?

    Vote the answer(s) that helped you to solve your issue(s)

    J 1 Reply Last reply 31 May 2021, 16:03
    0
    • K koahnig
      31 May 2021, 15:05

      My app generates a folder on "/storage/emulated/0/Android/data" following the common rules of "<country code>.<company>.<app name>". Upto including Android 10 this worked without an issue.

      QDir cur = QDir::current();
      cur.mkdir ("zz.yyyyyyyy.xxx");
      

      With Android 11 this does not create the folder reliably anymore. Sometimes it worked but on other occations it does not.

      Basically the app shall create a data folder accessible for other applications in order to transfer the output anywhere.

      I guess this is due to the new rules of storage management for Android 11.

      Any suggestions how to get around this?

      J Offline
      J Offline
      J.Hilk
      Moderators
      wrote on 31 May 2021, 16:03 last edited by J.Hilk
      #2

      @koahnig are you aware of
      https://www.qt.io/blog/2017/12/01/sharing-files-android-ios-qt-app

      the external folder for sharing works, afaik, still on all android versions

      Or at least, I based ma classes on it, and I have yet to hear from someone where it does not work


      Be aware of the Qt Code of Conduct, when posting : https://forum.qt.io/topic/113070/qt-code-of-conduct


      Q: What's that?
      A: It's blue light.
      Q: What does it do?
      A: It turns blue.

      K 1 Reply Last reply 31 May 2021, 16:49
      2
      • J J.Hilk
        31 May 2021, 16:03

        @koahnig are you aware of
        https://www.qt.io/blog/2017/12/01/sharing-files-android-ios-qt-app

        the external folder for sharing works, afaik, still on all android versions

        Or at least, I based ma classes on it, and I have yet to hear from someone where it does not work

        K Offline
        K Offline
        koahnig
        wrote on 31 May 2021, 16:49 last edited by
        #3

        @J-Hilk

        Thanks for reminder. Yes, I am aware of this.
        So far the other method was much easier.

        Vote the answer(s) that helped you to solve your issue(s)

        J 1 Reply Last reply 1 Jun 2021, 06:15
        0
        • K koahnig
          31 May 2021, 16:49

          @J-Hilk

          Thanks for reminder. Yes, I am aware of this.
          So far the other method was much easier.

          J Offline
          J Offline
          J.Hilk
          Moderators
          wrote on 1 Jun 2021, 06:15 last edited by
          #4

          @koahnig said in Android 11 QDir::mkDir() does not always work:

          So far the other method was much easier.

          nothing good is ever easy :P

          that said, there is also android:requestLegacyExternalStorage="true"
          https://forum.qt.io/topic/121837/cannot-open-device-s-image-after-targeting-api-29-on-android-x-device/3

          Maybe thats enough for your case?


          Be aware of the Qt Code of Conduct, when posting : https://forum.qt.io/topic/113070/qt-code-of-conduct


          Q: What's that?
          A: It's blue light.
          Q: What does it do?
          A: It turns blue.

          J 1 Reply Last reply 1 Jun 2021, 06:34
          0
          • J J.Hilk
            1 Jun 2021, 06:15

            @koahnig said in Android 11 QDir::mkDir() does not always work:

            So far the other method was much easier.

            nothing good is ever easy :P

            that said, there is also android:requestLegacyExternalStorage="true"
            https://forum.qt.io/topic/121837/cannot-open-device-s-image-after-targeting-api-29-on-android-x-device/3

            Maybe thats enough for your case?

            J Offline
            J Offline
            JKSH
            Moderators
            wrote on 1 Jun 2021, 06:34 last edited by JKSH 6 Jan 2021, 06:35
            #5

            @J-Hilk said in Android 11 QDir::mkDir() does not always work:

            there is also android:requestLegacyExternalStorage="true"
            https://forum.qt.io/topic/121837/cannot-open-device-s-image-after-targeting-api-29-on-android-x-device/3

            Maybe thats enough for your case?

            requestLegacyExternalStorage works on Android 10 but is no longer supported on Android 11 and newer, unfortunately: https://lists.qt-project.org/pipermail/interest/2021-May/037085.html

            I don't know what the full fix is in Qt, but the app needs to use Scoped Storage somehow: https://source.android.com/devices/storage/scoped

            Qt Doc Search for browsers: forum.qt.io/topic/35616/web-browser-extension-for-improved-doc-searches

            K 1 Reply Last reply 1 Jun 2021, 07:59
            2
            • J JKSH
              1 Jun 2021, 06:34

              @J-Hilk said in Android 11 QDir::mkDir() does not always work:

              there is also android:requestLegacyExternalStorage="true"
              https://forum.qt.io/topic/121837/cannot-open-device-s-image-after-targeting-api-29-on-android-x-device/3

              Maybe thats enough for your case?

              requestLegacyExternalStorage works on Android 10 but is no longer supported on Android 11 and newer, unfortunately: https://lists.qt-project.org/pipermail/interest/2021-May/037085.html

              I don't know what the full fix is in Qt, but the app needs to use Scoped Storage somehow: https://source.android.com/devices/storage/scoped

              K Offline
              K Offline
              koahnig
              wrote on 1 Jun 2021, 07:59 last edited by
              #6

              @JKSH said in Android 11 QDir::mkDir() does not always work:

              @J-Hilk said in Android 11 QDir::mkDir() does not always work:

              there is also android:requestLegacyExternalStorage="true"
              https://forum.qt.io/topic/121837/cannot-open-device-s-image-after-targeting-api-29-on-android-x-device/3

              Maybe thats enough for your case?

              requestLegacyExternalStorage works on Android 10 but is no longer supported on Android 11 and newer, unfortunately: https://lists.qt-project.org/pipermail/interest/2021-May/037085.html

              I don't know what the full fix is in Qt, but the app needs to use Scoped Storage somehow: https://source.android.com/devices/storage/scoped

              I have tried that but it does not work on Android 11.

              Unfortnately, the example of https://www.qt.io/blog/2017/12/01/sharing-files-android-ios-qt-app does not work either with Qt5.15.2.
              I remember that I got it to work a year ago, but it doesn't with the new version anymore. Got stuck after starting. Also debugging does not work. Great start for today :(

              Vote the answer(s) that helped you to solve your issue(s)

              ekkescornerE L 2 Replies Last reply 1 Jun 2021, 15:22
              0
              • K koahnig
                1 Jun 2021, 07:59

                @JKSH said in Android 11 QDir::mkDir() does not always work:

                @J-Hilk said in Android 11 QDir::mkDir() does not always work:

                there is also android:requestLegacyExternalStorage="true"
                https://forum.qt.io/topic/121837/cannot-open-device-s-image-after-targeting-api-29-on-android-x-device/3

                Maybe thats enough for your case?

                requestLegacyExternalStorage works on Android 10 but is no longer supported on Android 11 and newer, unfortunately: https://lists.qt-project.org/pipermail/interest/2021-May/037085.html

                I don't know what the full fix is in Qt, but the app needs to use Scoped Storage somehow: https://source.android.com/devices/storage/scoped

                I have tried that but it does not work on Android 11.

                Unfortnately, the example of https://www.qt.io/blog/2017/12/01/sharing-files-android-ios-qt-app does not work either with Qt5.15.2.
                I remember that I got it to work a year ago, but it doesn't with the new version anymore. Got stuck after starting. Also debugging does not work. Great start for today :(

                ekkescornerE Offline
                ekkescornerE Offline
                ekkescorner
                Qt Champions 2016
                wrote on 1 Jun 2021, 15:22 last edited by
                #7

                @koahnig said in Android 11 QDir::mkDir() does not always work:

                Unfortnately, the example of https://www.qt.io/blog/2017/12/01/sharing-files-android-ios-qt-app does not work either with Qt5.15.2.

                mea culpa - I have used Qt 5.13.2 on macOS Mojave for Android / iOS all the time and much work on 5 customer projects, so I didn't want to change a running system. But now I must upgrade - need XCode12 to upload to app store ;-)
                will take some time until all my projects are up and running using Qt 5.15
                then I'll take a look at sharing and also HowTo deal with scoped files - one customer will need this

                ekke ... Qt Champion 2016 | 2024 ... mobile business apps
                5.15 --> 6.8 https://t1p.de/ekkeChecklist
                QMake --> CMake https://t1p.de/ekkeCMakeMobileApps

                K 1 Reply Last reply 1 Jun 2021, 17:03
                2
                • ekkescornerE ekkescorner
                  1 Jun 2021, 15:22

                  @koahnig said in Android 11 QDir::mkDir() does not always work:

                  Unfortnately, the example of https://www.qt.io/blog/2017/12/01/sharing-files-android-ios-qt-app does not work either with Qt5.15.2.

                  mea culpa - I have used Qt 5.13.2 on macOS Mojave for Android / iOS all the time and much work on 5 customer projects, so I didn't want to change a running system. But now I must upgrade - need XCode12 to upload to app store ;-)
                  will take some time until all my projects are up and running using Qt 5.15
                  then I'll take a look at sharing and also HowTo deal with scoped files - one customer will need this

                  K Offline
                  K Offline
                  koahnig
                  wrote on 1 Jun 2021, 17:03 last edited by
                  #8

                  @ekkescorner

                  No problem.

                  I tried to go back Qt5.14.2 but that will not help. AFAIK going back Qt5.13 will not help either.

                  Some of the gradle has been adjusted. I can start the app, but there are display issues. The welcome to "Welcome to ekke's Share Example App" does not show.

                  After release compilation and starting the app the application output in creator shows:

                  I Perf    : Connecting to perf service.
                  I FeatureParser: can't find cepheus.xml in assets/device_features/,it may be in /system/etc/device_features
                  E libc    : Access denied finding property "ro.vendor.df.effect.conflict"
                  E Perf    : Fail to get file list lib
                  E Perf    : getFolderSize() : Exception_1 = java.lang.NullPointerException: Attempt to get length of null array
                  E Perf    : Fail to get file list debug-socket
                  E Perf    : getFolderSize() : Exception_1 = java.lang.NullPointerException: Attempt to get length of null array
                  E Perf    : Fail to get file list org.ekkescorner.examples.sharex
                  E Perf    : getFolderSize() : Exception_1 = java.lang.NullPointerException: Attempt to get length of null array
                  E Perf    : Fail to get file list org.ekkescorner.examples.sharex
                  E Perf    : getFolderSize() : Exception_1 = java.lang.NullPointerException: Attempt to get length of null array
                  E examples.share: Invalid ID 0x00000000.
                  E Qt      : Can't create main activity
                  E Qt      : android.content.res.Resources$NotFoundException: String array resource ID #0x0
                  E Qt      : 	at android.content.res.Resources.getStringArray(Resources.java:618)
                  E Qt      : 	at android.content.res.MiuiResources.getStringArray(MiuiResources.java:160)
                  E Qt      : 	at org.qtproject.qt5.android.bindings.QtLoader.startApp(QtLoader.java:423)
                  E Qt      : 	at org.qtproject.qt5.android.bindings.QtActivityLoader.onCreate(QtActivityLoader.java:166)
                  E Qt      : 	at org.qtproject.qt5.android.bindings.QtActivity.onCreateHook(QtActivity.java:267)
                  E Qt      : 	at org.qtproject.qt5.android.bindings.QtActivity.onCreate(QtActivity.java:274)
                  E Qt      : 	at org.ekkescorner.examples.sharex.QShareActivity.onCreate(QShareActivity.java:61)
                  E Qt      : 	at android.app.Activity.performCreate(Activity.java:7894)
                  E Qt      : 	at android.app.Activity.performCreate(Activity.java:7881)
                  E Qt      : 	at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1307)
                  E Qt      : 	at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3283)
                  E Qt      : 	at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3457)
                  E Qt      : 	at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:83)
                  E Qt      : 	at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:135)
                  E Qt      : 	at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:95)
                  E Qt      : 	at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2044)
                  E Qt      : 	at android.os.Handler.dispatchMessage(Handler.java:107)
                  E Qt      : 	at android.os.Looper.loop(Looper.java:224)
                  E Qt      : 	at android.app.ActivityThread.main(ActivityThread.java:7560)
                  E Qt      : 	at java.lang.reflect.Method.invoke(Native Method)
                  E Qt      : 	at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:539)
                  E Qt      : 	at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:950)
                  D ekkescorner: onCreate QShareActivity
                  D View    : org.ekkescorner.examples.sharex initForcedUseForceDark: 1
                  I AdrenoGLES: QUALCOMM build                   : 4d7a98b, Ic1977df6c2
                  I AdrenoGLES: Build Date                       : 09/16/20
                  I AdrenoGLES: OpenGL ES Shader Compiler Version: EV031.27.05.01
                  I AdrenoGLES: Local Branch                     :
                  I AdrenoGLES: Remote Branch                    : refs/tags/AU_LINUX_ANDROID_LA.UM.8.1.R1.09.00.00.529.087
                  I AdrenoGLES: Remote Branch                    : NONE
                  I AdrenoGLES: Reconstruct Branch               : NOTHING
                  I AdrenoGLES: Build Config                     : S P 8.0.11 AArch64
                  I AdrenoGLES: PFP: 0x016ee187, ME: 0x00000000
                  W AdrenoUtils: <ReadGpuID_from_sysfs:194>: Failed to open /sys/class/kgsl/kgsl-3d0/gpu_model
                  W AdrenoUtils: <ReadGpuID:218>: Failed to read chip ID from gpu_model. Fallback to use the GSL path
                  W Gralloc3: mapper 3.x is not supported
                  I examples.share: ProcessProfilingInfo new_methods=41 is saved saved_to_disk=1 resolve_classes_delay=8000
                  

                  Compiled and started in debug mode

                  killall: gdbserver: No such process
                  
                  18:58:35: Debugging starts
                  I examples.share: Late-enabling -Xcheck:jni
                  E examples.share: Unknown bits set in runtime_flags: 0x8000
                  W ActivityThread: Application org.ekkescorner.examples.sharex is waiting for the debugger on port 8100...
                  I System.out: Sending WAIT chunk
                  I System.out: Debugger has connected
                  I System.out: waiting for debugger to settle...
                  I System.out: waiting for debugger to settle...
                  I System.out: waiting for debugger to settle...
                  Could not load shared library symbols for 277 libraries, e.g. /system/lib64/libandroid_runtime.so.
                  Use the "info sharedlibrary" command to see the complete listing.
                  Do you need "set solib-search-path" or "set sysroot"?I System.out: debugger has settled (1829)
                  I Perf    : Connecting to perf service.
                  I FeatureParser: can't find cepheus.xml in assets/device_features/,it may be in /system/etc/device_features
                  E libc    : Access denied finding property "ro.vendor.df.effect.conflict"
                  W examples.sharex: type=1400 audit(0.0:35376): avc: denied { read } for name="u:object_r:vendor_displayfeature_prop:s0" dev="tmpfs" ino=17377 scontext=u:r:untrusted_app_27:s0:c84,c257,c512,c768 tcontext=u:object_r:vendor_displayfeature_prop:s0 tclass=file permissive=0
                  E Perf    : Fail to get file list lib
                  E Perf    : getFolderSize() : Exception_1 = java.lang.NullPointerException: Attempt to get length of null array
                  E Perf    : Fail to get file list debug-socket
                  E Perf    : getFolderSize() : Exception_1 = java.lang.NullPointerException: Attempt to get length of null array
                  E Perf    : Fail to get file list org.ekkescorner.examples.sharex
                  E Perf    : getFolderSize() : Exception_1 = java.lang.NullPointerException: Attempt to get length of null array
                  E Perf    : Fail to get file list org.ekkescorner.examples.sharex
                  E Perf    : getFolderSize() : Exception_1 = java.lang.NullPointerException: Attempt to get length of null array
                  W Looper  : Slow Looper main: Long Msg: seq=2 plan=18:58:34.576  late=0ms wall=2903ms running=408ms runnable=3ms io=3ms h=android.app.ActivityThread$H w=110
                  E examples.share: Invalid ID 0x00000000.
                  E Qt      : Can't create main activity
                  E Qt      : android.content.res.Resources$NotFoundException: String array resource ID #0x0
                  E Qt      : 	at android.content.res.Resources.getStringArray(Resources.java:618)
                  E Qt      : 	at android.content.res.MiuiResources.getStringArray(MiuiResources.java:160)
                  E Qt      : 	at org.qtproject.qt5.android.bindings.QtLoader.startApp(QtLoader.java:423)
                  E Qt      : 	at org.qtproject.qt5.android.bindings.QtActivityLoader.onCreate(QtActivityLoader.java:166)
                  E Qt      : 	at org.qtproject.qt5.android.bindings.QtActivity.onCreateHook(QtActivity.java:267)
                  E Qt      : 	at org.qtproject.qt5.android.bindings.QtActivity.onCreate(QtActivity.java:274)
                  E Qt      : 	at org.ekkescorner.examples.sharex.QShareActivity.onCreate(QShareActivity.java:61)
                  E Qt      : 	at android.app.Activity.performCreate(Activity.java:7894)
                  E Qt      : 	at android.app.Activity.performCreate(Activity.java:7881)
                  E Qt      : 	at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1307)
                  E Qt      : 	at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3283)
                  E Qt      : 	at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3457)
                  E Qt      : 	at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:83)
                  E Qt      : 	at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:135)
                  E Qt      : 	at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:95)
                  E Qt      : 	at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2044)
                  E Qt      : 	at android.os.Handler.dispatchMessage(Handler.java:107)
                  E Qt      : 	at android.os.Looper.loop(Looper.java:224)
                  E Qt      : 	at android.app.ActivityThread.main(ActivityThread.java:7560)
                  E Qt      : 	at java.lang.reflect.Method.invoke(Native Method)
                  E Qt      : 	at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:539)
                  E Qt      : 	at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:950)
                  D ekkescorner: onCreate QShareActivity
                  D View    : org.ekkescorner.examples.sharex initForcedUseForceDark: 1
                  W Looper  : Slow Looper main: Activity org.ekkescorner.examples.sharex/.QShareActivity is 2821ms late (wall=244ms running=219ms ClientTransaction{ callbacks=[android.app.servertransaction.LaunchActivityItem] lifecycleRequest=android.app.servertransaction.ResumeActivityItem }) because of 1 msg, msg 1 took 2903ms (seq=2 running=408ms runnable=3ms io=3ms h=android.app.ActivityThread$H w=110)
                  W Looper  : Slow Looper main: Activity org.ekkescorner.examples.sharex/.QShareActivity is 3066ms late (wall=1ms running=0ms ClientTransaction{ callbacks=[android.app.servertransaction.TopResumedActivityChangeItem] }) because of 2 msg, msg 1 took 2903ms (seq=2 running=408ms runnable=3ms io=3ms h=android.app.ActivityThread$H w=110), msg 2 took 244ms (seq=3 running=219ms runnable=6ms io=5ms late=2821ms h=android.app.ActivityThread$H w=159)
                  I AdrenoGLES: QUALCOMM build                   : 4d7a98b, Ic1977df6c2
                  I AdrenoGLES: Build Date                       : 09/16/20
                  I AdrenoGLES: OpenGL ES Shader Compiler Version: EV031.27.05.01
                  I AdrenoGLES: Local Branch                     :
                  I AdrenoGLES: Remote Branch                    : refs/tags/AU_LINUX_ANDROID_LA.UM.8.1.R1.09.00.00.529.087
                  I AdrenoGLES: Remote Branch                    : NONE
                  I AdrenoGLES: Reconstruct Branch               : NOTHING
                  I AdrenoGLES: Build Config                     : S P 8.0.11 AArch64
                  Could not load shared library symbols for /vendor/lib64/hw/gralloc.msmnile.so.
                  Do you need "set solib-search-path" or "set sysroot"?I AdrenoGLES: PFP: 0x016ee187, ME: 0x00000000
                  W AdrenoUtils: <ReadGpuID_from_sysfs:194>: Failed to open /sys/class/kgsl/kgsl-3d0/gpu_model
                  W AdrenoUtils: <ReadGpuID:218>: Failed to read chip ID from gpu_model. Fallback to use the GSL path
                  W RenderThread: type=1400 audit(0.0:35377): avc: denied { search } for name="kgsl" dev="sysfs" ino=55589 scontext=u:r:untrusted_app_27:s0:c84,c257,c512,c768 tcontext=u:object_r:sysfs_kgsl:s0 tclass=dir permissive=0
                  W Gralloc3: mapper 3.x is not supported
                  Could not load shared library symbols for /system/lib64/libboost.so.
                  Do you need "set solib-search-path" or "set sysroot"?I examples.share: ProcessProfilingInfo new_methods=41 is saved saved_to_disk=1 resolve_classes_delay=8000
                  

                  Both are compiled for arm64-v8a.

                  This is a screenshot of what is shown on the screen. Same thing on Android 9, 10 and 11.

                  signal-2021-06-01-190045.jpeg

                  Vote the answer(s) that helped you to solve your issue(s)

                  1 Reply Last reply
                  0
                  • K Offline
                    K Offline
                    koahnig
                    wrote on 8 Jun 2021, 08:10 last edited by
                    #9

                    There is already an update available on Git from @HomDX (presumably).

                    https://github.com/homdx/ekkesSHAREexample/tree/feature/Qt-5.15.0

                    That fix is compilable for Qt5.15.2 on Windows and it does work.

                    The issue has been marked as solved, because following the route of @J-Hilk seems to be the best option.

                    Vote the answer(s) that helped you to solve your issue(s)

                    1 Reply Last reply
                    2
                    • K koahnig
                      1 Jun 2021, 07:59

                      @JKSH said in Android 11 QDir::mkDir() does not always work:

                      @J-Hilk said in Android 11 QDir::mkDir() does not always work:

                      there is also android:requestLegacyExternalStorage="true"
                      https://forum.qt.io/topic/121837/cannot-open-device-s-image-after-targeting-api-29-on-android-x-device/3

                      Maybe thats enough for your case?

                      requestLegacyExternalStorage works on Android 10 but is no longer supported on Android 11 and newer, unfortunately: https://lists.qt-project.org/pipermail/interest/2021-May/037085.html

                      I don't know what the full fix is in Qt, but the app needs to use Scoped Storage somehow: https://source.android.com/devices/storage/scoped

                      I have tried that but it does not work on Android 11.

                      Unfortnately, the example of https://www.qt.io/blog/2017/12/01/sharing-files-android-ios-qt-app does not work either with Qt5.15.2.
                      I remember that I got it to work a year ago, but it doesn't with the new version anymore. Got stuck after starting. Also debugging does not work. Great start for today :(

                      L Offline
                      L Offline
                      lemons
                      wrote on 15 Dec 2021, 10:08 last edited by lemons
                      #10

                      @koahnig

                      for me the following worked:

                      1. add this to your AndroidManifest
                          <queries>
                                  <intent>
                                      <action android:name="android.intent.action.VIEW"/>
                                      <data android:mimeType="*/*"/>
                                  </intent>
                                  <intent>
                                      <action android:name="android.intent.action.EDIT"/>
                                      <data android:mimeType="*/*"/>
                                  </intent>
                                  <intent>
                                      <action android:name="android.intent.action.SEND"/>
                                      <data android:mimeType="*/*"/>
                                  </intent>
                              </queries>
                      </manifest>
                      
                      1. remove the isLowerOrEqualsKitKat clause in QShareUtils.java::createCustomChooserAndStartActivity
                      public static boolean createCustomChooserAndStartActivity(Intent theIntent, String title, int requestId, Uri uri) {
                              // ...
                              for (ResolveInfo appInfo : appInfoList) {
                                  // ... 
                                  // seems to fix the issue on Android 11 as well
                                  context.grantUriPermission(targetPackageName, uri, Intent.FLAG_GRANT_READ_URI_PERMISSION | Intent.FLAG_GRANT_WRITE_URI_PERMISSION);
                                  /*
                                  if(isLowerOrEqualsKitKat) {
                                      Log.d("ekkescorner", "legacy support grantUriPermission");
                                      context.grantUriPermission(targetPackageName, uri, Intent.FLAG_GRANT_READ_URI_PERMISSION | Intent.FLAG_GRANT_WRITE_URI_PERMISSION);
                                      // attention: you must revoke the permission later, so this only makes sense with getting back a result to know that Intent was done
                                      // I always move or delete the file, so I don't revoke permission
                                  }
                                  */
                              }
                              //...
                      }
                      
                      ekkescornerE 1 Reply Last reply 17 Nov 2022, 17:40
                      4
                      • L lemons
                        15 Dec 2021, 10:08

                        @koahnig

                        for me the following worked:

                        1. add this to your AndroidManifest
                            <queries>
                                    <intent>
                                        <action android:name="android.intent.action.VIEW"/>
                                        <data android:mimeType="*/*"/>
                                    </intent>
                                    <intent>
                                        <action android:name="android.intent.action.EDIT"/>
                                        <data android:mimeType="*/*"/>
                                    </intent>
                                    <intent>
                                        <action android:name="android.intent.action.SEND"/>
                                        <data android:mimeType="*/*"/>
                                    </intent>
                                </queries>
                        </manifest>
                        
                        1. remove the isLowerOrEqualsKitKat clause in QShareUtils.java::createCustomChooserAndStartActivity
                        public static boolean createCustomChooserAndStartActivity(Intent theIntent, String title, int requestId, Uri uri) {
                                // ...
                                for (ResolveInfo appInfo : appInfoList) {
                                    // ... 
                                    // seems to fix the issue on Android 11 as well
                                    context.grantUriPermission(targetPackageName, uri, Intent.FLAG_GRANT_READ_URI_PERMISSION | Intent.FLAG_GRANT_WRITE_URI_PERMISSION);
                                    /*
                                    if(isLowerOrEqualsKitKat) {
                                        Log.d("ekkescorner", "legacy support grantUriPermission");
                                        context.grantUriPermission(targetPackageName, uri, Intent.FLAG_GRANT_READ_URI_PERMISSION | Intent.FLAG_GRANT_WRITE_URI_PERMISSION);
                                        // attention: you must revoke the permission later, so this only makes sense with getting back a result to know that Intent was done
                                        // I always move or delete the file, so I don't revoke permission
                                    }
                                    */
                                }
                                //...
                        }
                        
                        ekkescornerE Offline
                        ekkescornerE Offline
                        ekkescorner
                        Qt Champions 2016
                        wrote on 17 Nov 2022, 17:40 last edited by
                        #11

                        @lemons just run into problems to send files in one of my customer apps with API 30 and Android 13 devices.
                        did your changes here and all works as expected.
                        will update my share example app.
                        THX

                        ekke ... Qt Champion 2016 | 2024 ... mobile business apps
                        5.15 --> 6.8 https://t1p.de/ekkeChecklist
                        QMake --> CMake https://t1p.de/ekkeCMakeMobileApps

                        1 Reply Last reply
                        2

                        • Login

                        • Login or register to search.
                        • First post
                          Last post
                        0
                        • Categories
                        • Recent
                        • Tags
                        • Popular
                        • Users
                        • Groups
                        • Search
                        • Get Qt Extensions
                        • Unsolved