Java – QT for Android – startactivityforresult equivalent does not work

QT for Android has few recorded functions - we can use the intent function of JNI (Java Native Interface). There are some examples equivalent to startactivity, but I can't find any results

This is the Java code of ilustration I want to do:

Intent intent = new Intent(Intent.ACTION_GET_CONTENT);
intent.setType("file/*");
getActivity().startActivityForResult(intent, 1);

I use documentation to write equivalent files in QT:

QAndroidJniObject ACTION_GET_CONTENT = QAndroidJniObject::getStaticObjectField<jstring>("android/content/Intent", "ACTION_GET_CONTENT");
QAndroidJniObject intent("android/content/Intent");
if (ACTION_GET_CONTENT.isValid() && intent.isValid()) {
    intent.callObjectMethod("setAction", "(Ljava/lang/string;)V", ACTION_GET_CONTENT.object<jstring>());
    intent.callObjectMethod("setType", "(Ljava/lang/string;)V", QAndroidJniObject::fromString("file/*").object<jstring>());
    QtAndroid::startActivity(intent, EXISTING_FILE_NAME_REQUEST, receiver);
    return true;
} else {
    return false;
}

Receiver is a pointer to a class object, which extends the abstract class qadroidactivityresultreceiver. This is the implementation of the virtual function handleactivityresult:

void MyReceiver::handleActivityResult(int receiverRequestCode, int resultCode, const QAndroidJniObject &data)
{
    jint RESULT_OK = QAndroidJniObject::getStaticField<jint>("android/app/Activity", "RESULT_OK");
    if (receiverRequestCode == EXISTING_FILE_NAME_REQUEST && resultCode == RESULT_OK) {
        QString path = data.callObjectMethod("getData", "()Landroid/net/Uri;").callObjectMethod("getPath", "()Ljava/lang/String;").toString();
        _dialog->emitExistingFileNameReady(path);
    } else {
        _dialog->emitExistingFileNameReady(QString());
    }
}

There is a problem with my code because when I run it, the following error message appears (and the program is aborting):

F/art     ( 6837): art/runtime/check_jni.cc:65] JNI DETECTED ERROR IN APPLICATION: JNI NewGlobalRef called with pending exception 'android.content.ActivityNotFoundException' thrown in unkNown throw location
F/art     ( 6837): art/runtime/check_jni.cc:65]     in call to NewGlobalRef
F/art     ( 6837): art/runtime/check_jni.cc:65] "QtThread" prio=5 tid=15 Runnable
F/art     ( 6837): art/runtime/check_jni.cc:65]   | group="main" sCount=0 dsCount=0 obj=0x12e75100 self=0xaec43400
F/art     ( 6837): art/runtime/check_jni.cc:65]   | sysTid=6882 nice=0 cgrp=default sched=0/0 handle=0xb491b780
F/art     ( 6837): art/runtime/check_jni.cc:65]   | state=R schedstat=( 0 0 0 ) utm=39 stm=20 core=0 HZ=100
F/art     ( 6837): art/runtime/check_jni.cc:65]   | stack=0xa2b04000-0xa2b
Intent intent = new Intent(Intent.ACTION_GET_CONTENT);
intent.setType("file/*");
getActivity().startActivityForResult(intent, 1);

stackSize=1012KB
F/art ( 6837): art/runtime/check_jni.cc:65] | held mutexes= "mutator lock"(shared held)
F/art ( 6837): art/runtime/check_jni.cc:65] native: #00 pc 00004e64 /system/lib/libbacktrace_libc++.so (UnwindCurrent::Unwind(unsigned int, ucontext*)+23)
F/art ( 6837): art/runtime/check_jni.cc:65] native: #01 pc 00003665 /system/lib/libbacktrace_libc++.so (Backtrace::Unwind(unsigned int, ucontext*)+8)
F/art ( 6837): art/runtime/check_jni.cc:65] native: #02 pc 00256429 /system/lib/libart.so (art::DumpNativeStack(std::__1::basic_ostream<char, std::__1::char_traits<char> >&, int, char const*, art::mirror::ArtMethod*)+84)
F/art ( 6837): art/runtime/check_jni.cc:65] native: #03 pc 00238fe7 /system/lib/libart.so (art::Thread::Dump(std::__1::basic_ostream<char, std::__1::char_traits<char> >&) const+158)
F/art ( 6837): art/runtime/check_jni.cc:65] native: #04 pc 000b191b /system/lib/libart.so (art::JniAbort(char const*, char const*)+610)
F/art ( 6837): art/runtime/check_jni.cc:65] native: #05 pc 000b2055 /system/lib/libart.so (art::JniAbortF(char const*, char const*, ...)+68)
F/art ( 6837): art/runtime/check_jni.cc:65] native: #06 pc 000b530f /system/lib/libart.so (art::ScopedCheck::ScopedCheck(_jnienv*, int, char const*)+1346)
F/art ( 6837): art/runtime/check_jni.cc:65] native: #07 pc 000b66cd /system/lib/libart.so (art::CheckJNI::NewGlobalRef(_jnienv*, _jobject*)+28)
F/art ( 6837): art/runtime/check_jni.cc:65] native: #08 pc 001ea0a7 /data/app/org.qtproject.example.TouchImage-2/lib/arm/libQt5Core.so (QJNIObjectPrivate::QJNIObjectPrivate(_jobject*)+82)
F/art ( 6837): art/runtime/check_jni.cc:65] native: #09 pc 001ea69d /data/app/org.qtproject.example.TouchImage-2/lib/arm/libQt5Core.so (???)
F/art ( 6837): art/runtime/check_jni.cc:65] native: #10 pc 001ec719 /data/app/org.qtproject.example.TouchImage-2/lib/arm/libQt5Core.so (QJNIObjectPrivate::getStaticObjectField(char const*, char const*, char const*)+48)
F/art ( 6837): art/runtime/check_jni.cc:65] native: #11 pc 0017718d /data/app/org.qtproject.example.TouchImage-2/lib/arm/libQt5Core.so (???)
F/art ( 6837): art/runtime/check_jni.cc:65] native: #12 pc 00177a3d /data/app/org.qtproject.example.TouchImage-2/lib/arm/libQt5Core.so (QStandardPaths::writableLocation(QStandardPaths::StandardLocation)+860)
F/art ( 6837): art/runtime/check_jni.cc:65] native: #13 pc 0017841f /data/app/org.qtproject.example.TouchImage-2/lib/arm/libQt5Core.so (QStandardPaths::standardLocations(QStandardPaths::StandardLocation)+790)
F/art ( 6837): art/runtime/check_jni.cc:65] native: #14 pc 00013e5b /data/app/org.qtproject.example.TouchImage-2/lib/arm/libTouchImage.so (ApplicationController::openFileButtonClicked()+130)
F/art ( 6837): art/runtime/check_jni.cc:65] native: #15 pc 001cce4f /data/app/org.qtproject.example.TouchImage-2/lib/arm/libQt5Core.so (QMetaObject::activate(QObject*, int, int, void**)+394)
F/art ( 6837): art/runtime/check_jni.cc:65] native: #16 pc 00261987 /data/app/org.qtproject.example.TouchImage-2/lib/arm/libQt5Widgets.so (QAbstractButton::clicked(bool)+26)
F/art ( 6837): art/runtime/check_jni.cc:65] native: #17 pc 001460f9 /data/app/org.qtproject.example.TouchImage-2/lib/arm/libQt5Widgets.so (???)
F/art ( 6837): art/runtime/check_jni.cc:65] native: #18 pc 001468f7 /data/app/org.qtproject.example.TouchImage-2/lib/arm/libQt5Widgets.so (???)
F/art ( 6837): art/runtime/check_jni.cc:65] native: #19 pc 00146979 /data/app/org.qtproject.example.TouchImage-2/lib/arm/libQt5Widgets.so (QAbstractButton::mouseReleaseEvent(QMouseEvent*)+88)
F/art ( 6837): art/runtime/check_jni.cc:65] native: #20 pc 0019d509 /data/app/org.qtproject.example.TouchImage-2/lib/arm/libQt5Widgets.so (QToolButton::mouseReleaseEvent(QMouseEvent*)+4)
F/art ( 6837): art/runtime/check_jni.cc:65] native: #21 pc 00100bbd /data/app/org.qtproject.example.TouchImage-2/lib/arm/libQt5Widgets.so (QWidget::event(QEvent*)+536)
F/art ( 6837): art/runtime/check_jni.cc:65] native: #22 pc 0019d57d /data/app/org.qtproject.example.TouchImage-2/lib/arm/libQt5Widgets.so (QToolButton::event(QEvent*)+50)
F/art ( 6837): art/runtime/check_jni.cc:65] native: #23 pc 000e2a41 /data/app/org.qtproject.example.TouchImage-2/lib/arm/libQt5Widgets.so (QApplicationPrivate::notify_helper(QObject*, QEvent*)+104)
F/art ( 6837): art/runtime/check_jni.cc:65] native: #24 pc 000e5583 /data/app/org.qtproject.example.TouchImage-2/lib/arm/libQt5Widgets.so (QApplication::notify(QObject*, QEvent*)+1382)
F/art ( 6837): art/runtime/check_jni.cc:65] native: #25 pc 001ae40f /data/app/org.qtproject.example.TouchImage-2/lib/arm/libQt5Core.so (QCoreApplication::notifyInternal(QObject*, QEvent*)+62)
F/art ( 6837): art/runtime/check_jni.cc:65] native: #26 pc 000e4d5b /data/app/org.qtproject.example.TouchImage-2/lib/arm/libQt5Widgets.so (QApplicationPrivate::sendMouseEvent(QWidget*, QMouseEvent*, QWidget*, QWidget*, QWidget**, QPointer<QWidget>&, bool)+286)
F/art ( 6837): art/runtime/check_jni.cc:65] native: #27 pc 0010a19b /data/app/org.qtproject.example.TouchImage-2/lib/arm/libQt5Widgets.so (???)
F/art ( 6837): art/runtime/check_jni.cc:65] native: #28 pc 0010a8d3 /data/app/org.qtproject.example.TouchImage-2/lib/arm/libQt5Widgets.so (???)
F/art ( 6837): art/runtime/check_jni.cc:65] native: #29 pc 000e2a41 /data/app/org.qtproject.example.TouchImage-2/lib/arm/libQt5Widgets.so (QApplicationPrivate::notify_helper(QObject*, QEvent*)+104)
F/art ( 6837): art/runtime/check_jni.cc:65] native: #30 pc 000e5e53 /data/app/org.qtproject.example.TouchImage-2/lib/arm/libQt5Widgets.so (QApplication::notify(QObject*, QEvent*)+3638)
F/art ( 6837): art/runtime/check_jni.cc:65] native: #31 pc 001ae40f /data/app/org.qtproject.example.TouchImage-2/lib/arm/libQt5Core.so (QCoreApplication::notifyInternal(QObject*, QEvent*)+62)
F/art ( 6837): art/runtime/check_jni.cc:65] native: #32 pc 000a09cd /data/app/org.qtproject.example.TouchImage-2/lib/arm/libQt5Gui.so (QGuiApplicationPrivate::processMouseEvent(QWindowSystemInterfacePrivate::MouseEvent*)+516)
F/art ( 6837): art/runtime/check_jni.cc:65] native: #33 pc 000a06ed /data/app/org.qtproject.example.TouchImage-2/lib/arm/libQt5Gui.so (QGuiApplicationPrivate::processTouchEvent(QWindowSystemInterfacePrivate::TouchEvent*)+3492)
F/art ( 6837): art/runtime/check_jni.cc:65] native: #34 pc 000a1b13 /data/app/org.qtproject.example.TouchImage-2/lib/arm/libQt5Gui.so (QGuiApplicationPrivate::processWindowSystemEvent(QWindowSystemInterfacePrivate::WindowSystemEvent*)+382)
F/art ( 6837): art/runtime/check_jni.cc:65] native: #35 pc 00093181 /data/app/org.qtproject.example.TouchImage-2/lib/arm/libQt5Gui.so (QWindowSystemInterface::sendWindowSystemEvents(QFlags<QEventLoop::ProcessEventsFlag>)+20)
F/art ( 6837): art/runtime/check_jni.cc:65] native: #36 pc 00028135 /data/data/org.qtproject.example.TouchImage/qt-reserved-files/plugins/platforms/android/libqtforandroid.so (???)
F/art ( 6837): art/runtime/check_jni.cc:65] native: #37 pc 001ad533 /data/app/org.qtproject.example.TouchImage-2/lib/arm/libQt5Core.so (QEventLoop::processEvents(QFlags<QEventLoop::ProcessEventsFlag>)+14)
F/art ( 6837): art/runtime/check_jni.cc:65] native: #38 pc 001adc13 /data/app/org.qtproject.example.TouchImage-2/lib/arm/libQt5Core.so (QEventLoop::exec(QFlags<QEventLoop::ProcessEventsFlag>)+226)
F/art ( 6837): art/runtime/check_jni.cc:65] native: #39 pc 001b2527 /data/app/org.qtproject.example.TouchImage-2/lib/arm/libQt5Core.so (QCoreApplication::exec()+82)
F/art ( 6837): art/runtime/check_jni.cc:65] native: #40 pc 00012a41 /data/app/org.qtproject.example.TouchImage-2/lib/arm/libTouchImage.so (main+48)
F/art ( 6837): art/runtime/check_jni.cc:65] native: #41 pc 000190b5 /data/data/org.qtproject.example.TouchImage/qt-reserved-files/plugins/platforms/android/libqtforandroid.so (???)
F/art ( 6837): art/runtime/check_jni.cc:65] native: #42 pc 00016baf /system/lib/libc.so (__pthread_start(void*)+30)
F/art ( 6837): art/runtime/check_jni.cc:65] native: #43 pc 00014af3 /system/lib/libc.so (__start_thread+6)
F/art ( 6837): art/runtime/check_jni.cc:65] (no managed stack frames)
F/art ( 6837): art/runtime/check_jni.cc:65]
F/art ( 6837): art/runtime/runtime.cc:289] Runtime aborting...
F/art ( 6837): art/runtime/runtime.cc:289] Aborting thread:
F/art ( 6837): art/runtime/runtime.cc:289] "QtThread" prio=5 tid=15 Native
F/art ( 6837): art/runtime/runtime.cc:289] | group="" sCount=0 dsCount=0 obj=0x12e75100 self=0xaec43400
F/art ( 6837): art/runtime/runtime.cc:289] | sysTid=6882 nice=0 cgrp=default sched=0/0 handle=0xb491b780
F/art ( 6837): art/runtime/runtime.cc:289] | state=R schedstat=( 0 0 0 ) utm=42 stm=20 core=0 HZ=100
F/art ( 6837): art/runtime/runtime.cc:289] | stack=0xa2b04000-0xa2b

Intent intent = new Intent(Intent.ACTION_GET_CONTENT);
intent.setType("file/*");
getActivity().startActivityForResult(intent, 1);

stackSize=1012KB
F/art ( 6837): art/runtime/runtime.cc:289] | held mutexes= "abort lock" "mutator lock"(shared held)
F/art ( 6837): art/runtime/runtime.cc:289] native: #00 pc 00004e64 /system/lib/libbacktrace_libc++.so (UnwindCurrent::Unwind(unsigned int, ucontext*)+23)
F/art ( 6837): art/runtime/runtime.cc:289] native: #01 pc 00003665 /system/lib/libbacktrace_libc++.so (Backtrace::Unwind(unsigned int, ucontext*)+8)
F/art ( 6837): art/runtime/runtime.cc:289] native: #02 pc 00256429 /system/lib/libart.so (art::DumpNativeStack(std::__1::basic_ostream<char, std::__1::char_traits<char> >&, int, char const*, art::mirror::ArtMethod*)+84)
F/art ( 6837): art/runtime/runtime.cc:289] native: #03 pc 00238fe7 /system/lib/libart.so (art::Thread::Dump(std::__1::basic_ostream<char, std::__1::char_traits<char> >&) const+158)
F/art ( 6837): art/runtime/runtime.cc:289] native: #04 pc 0022881d /system/lib/libart.so (art::AbortState::DumpThread(std::__1::basic_ostream<char, std::__1::char_traits<char> >&, art::Thread*)+32)
F/art ( 6837): art/runtime/runtime.cc:289] native: #05 pc 00228abf /system/lib/libart.so (art::AbortState::Dump(std::__1::basic_ostream<char, std::__1::char_traits<char> >&)+410)
F/art ( 6837): art/runtime/runtime.cc:289] native: #06 pc 00228c7f /system/lib/libart.so (art::Runtime::Abort()+82)
F/art ( 6837): art/runtime/runtime.cc:289] native: #07 pc 000a7371 /system/lib/libart.so (art::LogMessage::~LogMessage()+1360)
F/art ( 6837): art/runtime/runtime.cc:289] native: #08 pc 000b1b17 /system/lib/libart.so (art::JniAbort(char const*, char const*)+1118)
F/art ( 6837): art/runtime/runtime.cc:289] native: #09 pc 000b2055 /system/lib/libart.so (art::JniAbortF(char const*, char const*, ...)+68)
F/art ( 6837): art/runtime/runtime.cc:289] native: #10 pc 000b530f /system/lib/libart.so (art::ScopedCheck::ScopedCheck(_jnienv*, int, char const*)+1346)
F/art ( 6837): art/runtime/runtime.cc:289] native: #11 pc 000b66cd /system/lib/libart.so (art::CheckJNI::NewGlobalRef(_jnienv*, _jobject*)+28)
F/art ( 6837): art/runtime/runtime.cc:289] native: #12 pc 001ea0a7 /data/app/org.qtproject.example.TouchImage-2/lib/arm/libQt5Core.so (QJNIObjectPrivate::QJNIObjectPrivate(_jobject*)+82)
F/art ( 6837): art/runtime/runtime.cc:289] native: #13 pc 001ea69d /data/app/org.qtproject.example.TouchImage-2/lib/arm/libQt5Core.so (???)
F/art ( 6837): art/runtime/runtime.cc:289] native: #14 pc 001ec719 /data/app/org.qtproject.example.TouchImage-2/lib/arm/libQt5Core.so (QJNIObjectPrivate::getStaticObjectField(char const*, char const*, char const*)+48)
F/art ( 6837): art/runtime/runtime.cc:289] native: #15 pc 0017718d /data/app/org.qtproject.example.TouchImage-2/lib/arm/libQt5Core.so (???)
F/art ( 6837): art/runtime/runtime.cc:289] native: #16 pc 00177a3d /data/app/org.qtproject.example.TouchImage-2/lib/arm/libQt5Core.so (QStandardPaths::writableLocation(QStandardPaths::StandardLocation)+860)
F/art ( 6837): art/runtime/runtime.cc:289] native: #17 pc 0017841f /data/app/org.qtproject.example.TouchImage-2/lib/arm/libQt5Core.so (QStandardPaths::standardLocations(QStandardPaths::StandardLocation)+790)
F/art ( 6837): art/runtime/runtime.cc:289] native: #18 pc 00013e5b /data/app/org.qtproject.example.TouchImage-2/lib/arm/libTouchImage.so (ApplicationController::openFileButtonClicked()+130)
F/art ( 6837): art/runtime/runtime.cc:289] native: #19 pc 001cce4f /data/app/org.qtproject.example.TouchImage-2/lib/arm/libQt5Core.so (QMetaObject::activate(QObject*, int, int, void**)+394)
F/art ( 6837): art/runtime/runtime.cc:289] native: #20 pc 00261987 /data/app/org.qtproject.example.TouchImage-2/lib/arm/libQt5Widgets.so (QAbstractButton::clicked(bool)+26)
F/art ( 6837): art/runtime/runtime.cc:289] native: #21 pc 001460f9 /data/app/org.qtproject.example.TouchImage-2/lib/arm/libQt5Widgets.so (???)
F/art ( 6837): art/runtime/runtime.cc:289] native: #22 pc 001468f7 /data/app/org.qtproject.example.TouchImage-2/lib/arm/libQt5Widgets.so (???)
F/art ( 6837): art/runtime/runtime.cc:289] native: #23 pc 00146979 /data/app/org.qtproject.example.TouchImage-2/lib/arm/libQt5Widgets.so (QAbstractButton::mouseReleaseEvent(QMouseEvent*)+88)
F/art ( 6837): art/runtime/runtime.cc:289] native: #24 pc 0019d509 /data/app/org.qtproject.example.TouchImage-2/lib/arm/libQt5Widgets.so (QToolButton::mouseReleaseEvent(QMouseEvent*)+4)
F/art ( 6837): art/runtime/runtime.cc:289] native: #25 pc 00100bbd /data/app/org.qtproject.example.TouchImage-2/lib/arm/libQt5Widgets.so (QWidget::event(QEvent*)+536)
F/art ( 6837): art/runtime/runtime.cc:289] native: #26 pc 0019d57d /data/app/org.qtproject.example.TouchImage-2/lib/arm/libQt5Widgets.so (QToolButton::event(QEvent*)+50)
F/art ( 6837): art/runtime/runtime.cc:289] native: #27 pc 000e2a41 /data/app/org.qtproject.example.TouchImage-2/lib/arm/libQt5Widgets.so (QApplicationPrivate::notify_helper(QObject*, QEvent*)+104)
F/art ( 6837): art/runtime/runtime.cc:289] native: #28 pc 000e5583 /data/app/org.qtproject.example.TouchImage-2/lib/arm/libQt5Widgets.so (QApplication::notify(QObject*, QEvent*)+1382)
F/art ( 6837): art/runtime/runtime.cc:289] native: #29 pc 001ae40f /data/app/org.qtproject.example.TouchImage-2/lib/arm/libQt5Core.so (QCoreApplication::notifyInternal(QObject*, QEvent*)+62)
F/art ( 6837): art/runtime/runtime.cc:289] native: #30 pc 000e4d5b /data/app/org.qtproject.example.TouchImage-2/lib/arm/libQt5Widgets.so (QApplicationPrivate::sendMouseEvent(QWidget*, QMouseEvent*, QWidget*, QWidget*, QWidget**, QPointer<QWidget>&, bool)+286)
F/art ( 6837): art/runtime/runtime.cc:289] native: #31 pc 0010a19b /data/app/org.qtproject.example.TouchImage-2/lib/arm/libQt5Widgets.so (???)
F/art ( 6837): art/runtime/runtime.cc:289] native: #32 pc 0010a8d3 /data/app/org.qtproject.example.TouchImage-2/lib/arm/libQt5Widgets.so (???)
F/art ( 6837): art/runtime/runtime.cc:289] native: #33 pc 000e2a41 /data/app/org.qtproject.example.TouchImage-2/lib/arm/libQt5Widgets.so (QApplicationPrivate::notify_helper(QObject*, QEvent*)+104)
F/art ( 6837): art/runtime/runtime.cc:289] native: #34 pc 000e5e53 /data/app/org.qtproject.example.TouchImage-2/lib/arm/libQt5Widgets.so (QApplication::notify(QObject*, QEvent*)+3638)
F/art ( 6837): art/runtime/runtime.cc:289] native: #35 pc 001ae40f /data/app/org.qtproject.example.TouchImage-2/lib/arm/libQt5Core.so (QCoreApplication::notifyInternal(QObject*, QEvent*)+62)
F/art ( 6837): art/runtime/runtime.cc:289] native: #36 pc 000a09cd /data/app/org.qtproject.example.TouchImage-2/lib/arm/libQt5Gui.so (QGuiApplicationPrivate::processMouseEvent(QWindowSystemInterfacePrivate::MouseEvent*)+516)
F/art ( 6837): art/runtime/runtime.cc:289] native: #37 pc 000a06ed /data/app/org.qtproject.example.TouchImage-2/lib/arm/libQt5Gui.so (QGuiApplicationPrivate::processTouchEvent(QWindowSystemInterfacePrivate::TouchEvent*)+3492)
F/art ( 6837): art/runtime/runtime.cc:289] native: #38 pc 000a1b13 /data/app/org.qtproject.example.TouchImage-2/lib/arm/libQt5Gui.so (QGuiApplicationPrivate::processWindowSystemEvent(QWindowSystemInterfacePrivate::WindowSystemEvent*)+382)
F/art ( 6837): art/runtime/runtime.cc:289] native: #39 pc 00093181 /data/app/org.qtproject.example.TouchImage-2/lib/arm/libQt5Gui.so (QWindowSystemInterface::sendWindowSystemEvents(QFlags<QEventLoop::ProcessEventsFlag>)+20)
F/art ( 6837): art/runtime/runtime.cc:289] native: #40 pc 00028135 /data/data/org.qtproject.example.TouchImage/qt-reserved-files/plugins/platforms/android/libqtforandroid.so (???)
F/art ( 6837): art/runtime/runtime.cc:289] native: #41 pc 001ad533 /data/app/org.qtproject.example.TouchImage-2/lib/arm/libQt5Core.so (QEventLoop::processEvents(QFlags<QEventLoop::ProcessEventsFlag>)+14)
F/art ( 6837): art/runtime/runtime.cc:289] native: #42 pc 001adc13 /data/app/org.qtproject.example.TouchImage-2/lib/arm/libQt5Core.so (QEventLoop::exec(QFlags<QEventLoop::ProcessEventsFlag>)+226)
F/art ( 6837): art/runtime/runtime.cc:289] native: #43 pc 001b2527 /data/app/org.qtproject.example.TouchImage-2/lib/arm/libQt5Core.so (QCoreApplication::exec()+82)
F/art ( 6837): art/runtime/runtime.cc:289] native: #44 pc 00012a41 /data/app/org.qtproject.example.TouchImage-2/lib/arm/libTouchImage.so (main+48)
F/art ( 6837): art/runtime/runtime.cc:289] native: #45 pc 000190b5 /data/data/org.qtproject.example.TouchImage/qt-reserved-files/plugins/platforms/android/libqtforandroid.so (???)
F/art ( 6837): art/runtime/runtime.cc:289] native: #46 pc 00016baf /system/lib/libc.so (__pthread_start(void*)+30)
F/art ( 6837): art/runtime/runtime.cc:289] native: #47 pc 00014af3 /system/lib/libc.so (__start_thread+6)
F/art ( 6837): art/runtime/runtime.cc:289] (no managed stack frames)
F/art ( 6837): art/runtime/runtime.cc:289] Pending exception android.content.ActivityNotFoundException thrown by 'unkNown throw location'
F/art ( 6837): art/runtime/runtime.cc:289] android.content.ActivityNotFoundException: No Activity found to handle Intent { }
F/art ( 6837): art/runtime/runtime.cc:289] at void android.app.Instrumentation.checkStartActivityResult(int, java.lang.Object) (Instrumentation.java:1781)
F/art ( 6837): art/runtime/runtime.cc:289] at android.app.Instrumentation$ActivityResult android.app.Instrumentation.execStartActivity(android.content.Context, android.os.IBinder, android.os.IBinder, android.app.Activity, android.content.Intent, int, android.os.Bundle) (Instrumentation.java:1501)
F/art ( 6837): art/runtime/runtime.cc:289] at void android.app.Activity.startActivityForResult(android.content.Intent, int, android.os.Bundle) (Activity.java:3745)
F/art ( 6837): art/runtime/runtime.cc:289] at void android.app.Activity.startActivityForResult(android.content.Intent, int) (Activity.java:3706)
F/art ( 6837): art/runtime/runtime.cc:289] Dumping all threads without appropriate locks held: thread list lock mutator lock
F/art ( 6837): art/runtime/runtime.cc:289] All threads:
F/art ( 6837): art/runtime/runtime.cc:289] DALVIK THREADS (16):
F/art ( 6837): art/runtime/runtime.cc:289] (no managed stack frames)
<< lot more lines of log here >>
F/libc ( 6837): Fatal signal 6 (SIGABRT), code -6 in tid 6882 (QtThread)


resolvent:

This is a stupid error. This is the wrong method signature (setaction and setType). Correct, working code:

QAndroidJniObject ACTION_GET_CONTENT = QAndroidJniObject::fromString("android.intent.action.GET_CONTENT");
QAndroidJniObject intent("android/content/Intent");
if (ACTION_GET_CONTENT.isValid() && intent.isValid()) {
    intent.callObjectMethod("setAction", "(Ljava/lang/String;)Landroid/content/Intent;", ACTION_GET_CONTENT.object<jstring>());
    intent.callObjectMethod("setType", "(Ljava/lang/String;)Landroid/content/Intent;", QAndroidJniObject::fromString("file/*").object<jstring>());
    QtAndroid::startActivity(intent.object<jobject>(), EXISTING_FILE_NAME_REQUEST, receiver);
    return true;
} else {
    return false;
}

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>