- iOS/Objective-C 元类和类别
- objective-c - -1001 错误,当 NSURLSession 通过 httpproxy 和/etc/hosts
- java - 使用网络类获取 url 地址
- ios - 推送通知中不播放声音
Qt for Android 中的功能文档很少——我们可以通过 JNI(Java native 接口(interface))使用 Intent 功能。有一些与 startActivity 等效的示例,但我没有找到任何具有结果接收的示例。
这是 Java 代码,说明了我想做的事情:
Intent intent = new Intent(Intent.ACTION_GET_CONTENT);
intent.setType("file/*");
getActivity().startActivityForResult(intent, 1);
我使用文档在 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是一个指向类对象的指针,它扩展了抽象类QAndroidActivityResultReceiver。这是虚函数 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());
}
}
我的代码有问题,因为当我运行它时,出现以下错误消息(并且程序正在中止):
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-0xa2b06000 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-0xa2b06000 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)
这发生在 QtAndroid::startActivity 之后和 MyReceiver::handleActivityResult 之前(调试器这样说)。更重要的是,在程序启动期间有警告/错误,但不会导致程序中止:
W/linker ( 4449): libQt5Gui.so: unused DT entry: type 0x1d arg 0x4c19d
W/linker ( 4449): libQt5Widgets.so: unused DT entry: type 0x1d arg 0x6a769
W/linker ( 4449): libQt5Svg.so: unused DT entry: type 0x1d arg 0x8f18
W/linker ( 4449): libQt5AndroidExtras.so: unused DT entry: type 0x1d arg 0x5044
W/linker ( 4449): libqtforandroid.so: unused DT entry: type 0x1d arg 0x8cac
I/Qt ( 4449): qt start
W/System.err( 4449): java.lang.NoSuchFieldException: mInsetState
W/System.err( 4449): at java.lang.Class.getDeclaredField(Class.java:890)
W/System.err( 4449): at org.qtproject.qt5.android.ExtractStyle.getAccessibleField(ExtractStyle.java:405)
W/System.err( 4449): at org.qtproject.qt5.android.ExtractStyle.getDrawable(ExtractStyle.java:1103)
W/System.err( 4449): at org.qtproject.qt5.android.ExtractStyle.getLayerDrawable(ExtractStyle.java:629)
W/System.err( 4449): at org.qtproject.qt5.android.ExtractStyle.getRippleDrawable(ExtractStyle.java:820)
W/System.err( 4449): at org.qtproject.qt5.android.ExtractStyle.getDrawable(ExtractStyle.java:1028)
W/System.err( 4449): at org.qtproject.qt5.android.ExtractStyle.extractViewInformations(ExtractStyle.java:1187)
W/System.err( 4449): at org.qtproject.qt5.android.ExtractStyle.extractTextAppearanceInformations(ExtractStyle.java:1336)
W/System.err( 4449): at org.qtproject.qt5.android.ExtractStyle.<init>(ExtractStyle.java:2017)
W/System.err( 4449): at org.qtproject.qt5.android.QtActivityDelegate.loadApplication(QtActivityDelegate.java:438)
W/System.err( 4449): at java.lang.reflect.Method.invoke(Native Method)
W/System.err( 4449): at java.lang.reflect.Method.invoke(Method.java:372)
W/System.err( 4449): at org.qtproject.qt5.android.bindings.QtActivity.loadApplication(QtActivity.java:245)
W/System.err( 4449): at org.qtproject.qt5.android.bindings.QtActivity.startApp(QtActivity.java:655)
W/System.err( 4449): at org.qtproject.qt5.android.bindings.QtActivity.onCreate(QtActivity.java:895)
W/System.err( 4449): at android.app.Activity.performCreate(Activity.java:5990)
W/System.err( 4449): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1106)
W/System.err( 4449): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2278)
W/System.err( 4449): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2387)
W/System.err( 4449): at android.app.ActivityThread.access$800(ActivityThread.java:151)
W/System.err( 4449): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1303)
W/System.err( 4449): at android.os.Handler.dispatchMessage(Handler.java:102)
W/System.err( 4449): at android.os.Looper.loop(Looper.java:135)
W/System.err( 4449): at android.app.ActivityThread.main(ActivityThread.java:5254)
W/System.err( 4449): at java.lang.reflect.Method.invoke(Native Method)
W/System.err( 4449): at java.lang.reflect.Method.invoke(Method.java:372)
W/System.err( 4449): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:903)
W/System.err( 4449): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:698)
W/System.err( 4449): java.lang.NullPointerException: Attempt to invoke virtual method 'java.lang.Object java.lang.reflect.Field.get(java.lang.Object)' on a null object reference
W/System.err( 4449): at org.qtproject.qt5.android.ExtractStyle.getDrawable(ExtractStyle.java:1103)
W/System.err( 4449): at org.qtproject.qt5.android.ExtractStyle.getLayerDrawable(ExtractStyle.java:629)
W/System.err( 4449): at org.qtproject.qt5.android.ExtractStyle.getRippleDrawable(ExtractStyle.java:820)
W/System.err( 4449): at org.qtproject.qt5.android.ExtractStyle.getDrawable(ExtractStyle.java:1028)
W/System.err( 4449): at org.qtproject.qt5.android.ExtractStyle.extractViewInformations(ExtractStyle.java:1187)
W/System.err( 4449): at org.qtproject.qt5.android.ExtractStyle.extractTextAppearanceInformations(ExtractStyle.java:1336)
W/System.err( 4449): at org.qtproject.qt5.android.ExtractStyle.<init>(ExtractStyle.java:2017)
W/System.err( 4449): at org.qtproject.qt5.android.QtActivityDelegate.loadApplication(QtActivityDelegate.java:438)
W/System.err( 4449): at java.lang.reflect.Method.invoke(Native Method)
W/System.err( 4449): at java.lang.reflect.Method.invoke(Method.java:372)
W/System.err( 4449): at org.qtproject.qt5.android.bindings.QtActivity.loadApplication(QtActivity.java:245)
W/System.err( 4449): at org.qtproject.qt5.android.bindings.QtActivity.startApp(QtActivity.java:655)
W/System.err( 4449): at org.qtproject.qt5.android.bindings.QtActivity.onCreate(QtActivity.java:895)
W/System.err( 4449): at android.app.Activity.performCreate(Activity.java:5990)
W/System.err( 4449): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1106)
W/System.err( 4449): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2278)
W/System.err( 4449): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2387)
W/System.err( 4449): at android.app.ActivityThread.access$800(ActivityThread.java:151)
W/System.err( 4449): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1303)
W/System.err( 4449): at android.os.Handler.dispatchMessage(Handler.java:102)
W/System.err( 4449): at android.os.Looper.loop(Looper.java:135)
W/System.err( 4449): at android.app.ActivityThread.main(ActivityThread.java:5254)
W/System.err( 4449): at java.lang.reflect.Method.invoke(Native Method)
W/System.err( 4449): at java.lang.reflect.Method.invoke(Method.java:372)
W/System.err( 4449): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:903)
W/System.err( 4449): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:698)
<< more lines of log here >>
W/linker ( 4449): libTouchImage.so: unused DT entry: type 0x1d arg 0x8efc
W/Qt A11Y ( 4449): Could not activate platform accessibility.
最佳答案
这是一个愚蠢的错误。这是错误的方法签名(setAction 和 setType。正确的工作代码:
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;
}
关于java - Qt for Android - startActivityForResult 等效项不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30411650/
我正在使用 Qt 语言学家翻译一个 ui 文件。我使用 lupdate 获取了它的 ts 文件,并翻译了这些单词和短语。现在我想将它添加到我的代码中,但我从它的教程中发现我似乎必须将 tr() 添加到
我想在 Qt Creator 中创建下面的简单控制台应用程序: #include int main(int argc, char* argv[]) { std::cout #include
我想将 libQtGui.so.4 libQtNetwork.so.4 和 libQtCore.so.4 包含在与我的应用程序所在的目录相同的目录中。我如何让 Qt 理解这一点? y 目的是拥有一个使
我有一个充满 QPushButtons 和 QLabels 以及各种其他有趣的 QWidget 的窗口,所有这些都使用各种 QLayout 对象动态布局...而我想做的是偶尔制作一些这些小部件变得不可
关闭。这个问题不符合Stack Overflow guidelines .它目前不接受答案。 这个问题似乎与 help center 中定义的范围内的编程无关。 . 关闭 7 年前。 Improve
我想知道 Qt 是否将下面代码的“版本 1”之类的东西放在堆上?在版本 1 中,Qt 会将 dirStuff 放在堆栈上还是堆上?我问是因为我有一种感觉,Java 将所有数据结构放在堆上......不
这个问题是关于 Qt Installer Framework 2.0 版的。 在这一点上,使用 Qt 安装程序框架的人都知道,如果不进行自定义,您根本无法通过安装程序覆盖现有安装。这样做显然是为了解决
关闭。这个问题是off-topic .它目前不接受答案。 想改善这个问题吗? Update the question所以它是 on-topic对于堆栈溢出。 8年前关闭。 Improve this q
因为我在我的计算机上安装了 Qt 4.8.4 和 Qt 5.1,所以我遇到了问题。 当只有 Qt 4.8.4 存在时,一切都很好。 当我添加 Qt 5.1 时,这个工作正常,但 Qt 4.8.4 给了
我无法在我的 Ubuntu 12 中安装更多软件包。我尝试了 apt-get install -f ,以及许多其他类似的技巧,但在找到解决方案方面没有进展。 这是属于 Qt 的损坏包: 以下包具有未满
我正在尝试使用 Virtual Box 中的 Ubuntu 机器复制我们目前在物理 Ubuntu 服务器上运行的应用程序。它是一个 QT 应用程序,但在服务器上我们使用 NPM 的 pm2 运行它。安
问题: Qt Creator 是用 Qt Creator 构建的吗? 同样,Qt Designer 是用 Qt Designer 构建的吗? 顺便说一句,为什么有两个 Qt IDE?他们是竞争对手吗?
当我使用 QWidget设计用户界面时,我总是对它的大小属性有点困惑。有size policy , geometry和 hintSize . 我只知道size policy之间的关系和 hintSiz
就目前而言,这个问题不适合我们的问答形式。我们希望答案得到事实、引用资料或专业知识的支持,但这个问题可能会引发辩论、争论、投票或扩展讨论。如果您觉得这个问题可以改进并可能重新打开,visit the
我想知道是否有一种很好的方法可以让用户像 LabView 一样创建节点图(有限制)。 像这样的东西: 我见过http://www.pyqtgraph.org/ ,这似乎有类似的东西,我确实打算使用 P
在 Qt 中是否有一种跨平台的方式来获得用户喜欢的固定宽度和比例字体? 例如,在 cocoa 中,有 NSFont *proportional = [NSFont userFontOfSize:12.
我想使用 Qt 和 C++ 制作这样的交互式图表:http://jsxgraph.uni-bayreuth.de/wiki/index.php/Cubic_spline_interpolation 关
我正在编写一个嵌入式设备屏幕的模拟(其中包含主 QWidget 顶部的自定义小部件),虽然屏幕的原始尺寸是 800x600,但我希望能够按比例放大和缩小它拖动窗口的角。如果不使用网格布局和担架(不会向
在下面的示例中,我是否必须从堆中删除对象?如果是的话,怎么办? #include #include #include #include #include int main(int argc,
来自 Web 开发背景,我现在进入 QT 应用程序开发。 使用 QFonts 我已经看到我显然只有两个选择,在 QT 中定义字体大小;按像素大小或点大小。 在制作网页布局时,我习惯于以相对方式定义所有
我是一名优秀的程序员,十分优秀!