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. QT android app creates file but it is invisible from computer

QT android app creates file but it is invisible from computer

Scheduled Pinned Locked Moved Solved Mobile and Embedded
3 Posts 2 Posters 481 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.
  • D Offline
    D Offline
    Diablillowilly
    wrote on last edited by
    #1

    Hi, Im testing an app in android, but when I create a file, It only appears from the phone file explorer, when I plug the phone to the pc I cant see that file, I made some investigation, and it seems I need to trigger MediaScannerConnection.scanFile(), so, I searched for an example or program which already does this in java, and I found this:
    https://github.com/benlau/androidnative.pri/blob/master/java/src/androidnative/MediaScanner.java

    but, it drops

    E:\app\build\android-build\src\myscan\scan.java:17: error: package SystemDispatcher does not exist
          SystemDispatcher.addListener(new SystemDispatcher.Listener() {
                                                           ^
    E:\app\build\android-build\src\myscan\scan.java:17: error: cannot find symbol
          SystemDispatcher.addListener(new SystemDispatcher.Listener() {
          ^
      symbol:   variable SystemDispatcher
      location: class scan
    Note: Some input files use or override a deprecated API.
    
    

    And when removing this block

    ```public static final String SCAN_FILE = "androidnative.MediaScanner.scanFile";
    
      static {
    
      SystemDispatcher.addListener(new SystemDispatcher.Listener() {
            public void onDispatched(String type, Map message) {
                if (type.equals(SCAN_FILE)) {
                    scanFile(message);
                }
            }
        });
    }```
    

    It drops a huge error stack (https://pastebin.com/C0EvVCL9), mainly saying
    E art : JNI DETECTED ERROR IN APPLICATION: JNI NewString called with pending exception java.lang.RuntimeException: Can't create handler inside thread that has not called Looper.prepare()

    So I how do you think I could fix it?

    ( I've already tried this stuff, but none of them worked):
    https://forum.qt.io/topic/68780/save-image-to-android-device
    https://forum.qt.io/topic/67426/trigger-an-android-media-scan
    https://stackoverflow.com/questions/30067330/create-a-directory-on-qt-android-can-see-it-on-mobile-but-can-not-see-it-on-com

    Thanks for reading

    1 Reply Last reply
    0
    • sierdzioS Offline
      sierdzioS Offline
      sierdzio
      Moderators
      wrote on last edited by
      #2

      Have you followed Ben's installation instructions? https://github.com/benlau/androidnative.pri/blob/master/docs/installation.md

      (Z(:^

      D 1 Reply Last reply
      2
      • sierdzioS sierdzio

        Have you followed Ben's installation instructions? https://github.com/benlau/androidnative.pri/blob/master/docs/installation.md

        D Offline
        D Offline
        Diablillowilly
        wrote on last edited by
        #3

        @sierdzio Actually no , I've just realized that that piece of code wont work without the rest of the library, so Im going to try to realize how is that specific method called, and how it works.

        1 Reply Last reply
        0

        • Login

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