OK, after some playing around, I think I got it, but now it crashes with the following output:
@E/AndroidRuntime(27949): FATAL EXCEPTION: Thread-14
E/AndroidRuntime(27949): android.content.ActivityNotFoundException: No Activity found to handle Intent { act=android.intent.action.VIEW dat=assets:/qml/DesignForAndroid/Papers/170.pdf }
E/AndroidRuntime(27949): at android.app.Instrumentation.checkStartActivityResult(Instrumentation.java:1535)
E/AndroidRuntime(27949): at android.app.Instrumentation.execStartActivity(Instrumentation.java:1387)
E/AndroidRuntime(27949): at android.app.Activity.startActivityForResult(Activity.java:3150)
E/AndroidRuntime(27949): at android.app.Activity.startActivity(Activity.java:3256)
E/AndroidRuntime(27949): at org.qtproject.qt5.android.QtNative.openURL(QtNative.java:115)
E/AndroidRuntime(27949): at dalvik.system.NativeStart.run(Native Method)@
My intention was to use the assets system (check above) to open the PDF files with Adobe Reader. I'm using the QDesktopServices::openURL() to open the file and this works if I use an absolute path (/mnt/sdcard/DCIM/Papers/170.pdf) but not if I use the relative one (assets:/qml/DesignForAndroid/Papers/170.pdf). Here's the code I'm using:
@bool ExternalFileStarter::openFile(QString fileName)
{
return QDesktopServices::openUrl(QUrl::fromLocalFile(fileName));
}@
I have noticed that when I try to search for files stored as assets on the Android device, they will not be found so I'm assuming that assets are something like qrc. That would explain why the asset files won't open (and the fact that fromLocalFile() adds a "file://").
So I'm back on square one, trying to figure out where does the application get stored on the Android device. I can't find it for the life of me, and using applicationFilePath() will return the file "app_process" which I assume is Android's and not my executable or rather, "app_process" runs the app. I've tried checking out the .pri file but I have no idea what's going on there and since the QML files also get stored as assets, they aren't much help. Thinking about it further, it could be that there is no way to get a relative path in the first place. What I mean is, I can't get the location of the package from Qt, and I think that where the package gets put differs from device to device.
Am I wrong or is there a way for me to get a relative path? If not, would it be possible to use qrc and then extract the files relative to the package? Any help would be most appreciated.