QT android app creates file but it is invisible from computer
-
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.javabut, 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-comThanks for reading
-
Have you followed Ben's installation instructions? https://github.com/benlau/androidnative.pri/blob/master/docs/installation.md
-
Have you followed Ben's installation instructions? https://github.com/benlau/androidnative.pri/blob/master/docs/installation.md
@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.