App crashing on QDesktopServices::openUrl

458 views
Skip to first unread message

Sebastian Diel

unread,
Mar 10, 2013, 8:50:50 AM3/10/13
to andro...@googlegroups.com
Hi,

I use this line
QDesktopServices::openUrl(QUrl::fromLocalFile(model->getAppPath()+"classintouch.pdf"));

to open a .pdf file. It works well on a Win client, on Android the App is being forced to finish.
This behaviour is probably related to https://bugs.kde.org/show_bug.cgi?id=307605
(For a deeper look I've added the crash log below. Reproducible: always)

Is there any workaround or alternative idea to open a .pdf from qt? I somehow have to display my help file...

Best regards,
Sebastian


This is the logcat excerpt:
D/Qtᅵᅵᅵᅵᅵ (22863): #if defined(Q_WS_QPA)
I/ActivityManager(ᅵ 389): START u0 {act=android.intent.action.VIEW dat=file:///data/data/org.kde.necessitas.example.classInTouch/files/classintouch.pdf} from pid 22863
W/dalvikvm(22863): threadid=11: thread exiting with uncaught exception (group=0x40b04930)
E/AndroidRuntime(22863): FATAL EXCEPTION: Thread-1790
E/AndroidRuntime(22863): android.content.ActivityNotFoundException: No Activity found to handle Intent { act=android.intent.action.VIEW dat=file:///data/data/org.kde.necessitas.example.classInTouch/files/classintouch.pdf }
E/AndroidRuntime(22863):ᅵᅵᅵᅵᅵᅵᅵ at android.app.Instrumentation.checkStartActivityResult(Instrumentation.java:1622)
E/AndroidRuntime(22863):ᅵᅵᅵᅵᅵᅵᅵ at android.app.Instrumentation.execStartActivity(Instrumentation.java:1417)
E/AndroidRuntime(22863):ᅵᅵᅵᅵᅵᅵᅵ at android.app.Activity.startActivityForResult(Activity.java:3370)
E/AndroidRuntime(22863):ᅵᅵᅵᅵᅵᅵᅵ at android.app.Activity.startActivityForResult(Activity.java:3331)
E/AndroidRuntime(22863):ᅵᅵᅵᅵᅵᅵᅵ at android.app.Activity.startActivity(Activity.java:3566)
E/AndroidRuntime(22863):ᅵᅵᅵᅵᅵᅵᅵ at android.app.Activity.startActivity(Activity.java:3534)
E/AndroidRuntime(22863):ᅵᅵᅵᅵᅵᅵᅵ at org.kde.necessitas.industrius.QtNative.openURL(QtNative.java:87)
E/AndroidRuntime(22863):ᅵᅵᅵᅵᅵᅵᅵ at dalvik.system.NativeStart.run(Native Method)
W/ActivityManager(ᅵ 389):ᅵᅵ Force finishing activity org.kde.necessitas.example.classInTouch/org.kde.necessitas.origo.QtActivity
D/mali_winsys(16619): new_window_surface returns 0x3000
I/Qt JAVA (22863): surfaceDestroyed
I/ActivityManager(ᅵ 389): No longer want com.google.android.gms (pid 22465): empty #17

MrOqto

unread,
Mar 12, 2013, 7:25:53 PM3/12/13
to andro...@googlegroups.com
I implemented this feature on my app recently to open web link using QDesktopServices::openUrl(.
To my surprise it worked without any issue. Android gives me a list of the installed web browsers and the link was opened.
I suggest you try to open web address with the
QDesktopServices::openUrl( to understand if your issue is related to files:: or PDF.
If you discover that your app still crash for web links, then I can send you an APK that uses the QDesktopService successfully , you compare the log with adb logcat.

 

Sebastian Diel

unread,
Mar 12, 2013, 7:48:56 PM3/12/13
to andro...@googlegroups.com
Thank you, MrOqto!


Am 13.03.2013 00:25, schrieb MrOqto:
I implemented this feature on my app recently to open web link using QDesktopServices::openUrl(.
I also use this successfully for web and mail links. The problem
occurs when opening *local* files. The aforementioned bug states
a reason for this:

"When trying to run a local file on Android, the MIME type needs
to be set as well for the Intent. "
(https://bugs.kde.org/show_bug.cgi?id=307605)

Unfortunately I didn't succeed in following the workaround
proposed in the bug by tomasl. I've searched for all "QtNative.java"
files on my developing Win machine and replaced the

"public static void openURL(String url)" in every single one of
those files.

by the alternative given in the bug report. Alas: no change, of
behaviour: the app still crashes in the same manner.

Any ideas on how I can make that workaround work?

Best regards,
Sebastian

Tony Wood

unread,
Mar 12, 2013, 8:18:37 PM3/12/13
to andro...@googlegroups.com
If this ends up as a show stopper for your development, I suggest you don't initiate the call in C++ through the QDesktopService API. Instead, you can pass the file path String to Java via JNI. Then use the Intent ACTION_VIEW Android API. You will be supporting this functionality independently of Qt.



--
You received this message because you are subscribed to a topic in the Google Groups "android-qt" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/android-qt/UpgBRz8Imwo/unsubscribe?hl=en.
To unsubscribe from this group and all its topics, send an email to android-qt+...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

Reply all
Reply to author
Forward
0 new messages