我需要获得主要活动,我尝试过:
QAndroidJniEnvironment jniEnv;
jclass clsAct = jniEnv->FindClass("android/app/Activity");
qDebug() << "Activity: " << clsAct;
if( QAndroidJniObject::isClassAvailable("org/qtproject/qt5/android/bindings/QtActivity") )
{
jclass clsApp = jniEnv->FindClass("org/qtproject/qt5/android/bindings/QtActivity");
qDebug() << "QtActivity: " << clsApp;
if( clsApp && clsAct )
{
jobject objAct = NULL;
jmethodID mid = jniEnv->GetStaticMethodID( clsApp, "activity", "()Landroid/app/Activity;" );
qDebug() << "activityMID: " << mid;
if( mid )
{
objAct = jniEnv->CallStaticObjectMethod( clsApp, mid );
qDebug() << "activityObj: " << objAct;
}
}
}
但在jniEnv->FindClass(“org/qtproject/qt5/android/bindings/QtActivity”)
拍摄错误:
D / Qt(4074):mainwindow.cpp:32 (MainWindow :: MainWindow(QWidget *)):&gt;&gt;&gt;&gt;&gt;&gt; QtActivity:0x0 W / dalvikvm(4074):JNI警告:JNI函数CallStaticVoidMethodV 调用异常待定W / dalvikvm(4074):in Ldalvik / system / NativeStart; .run :()V(CallStaticVoidMethodV) W / dalvikvm(4074):未决例外是:I / dalvikvm(4074): java.lang.NoClassDefFoundError: org / qtproject / qt5 / android / bindings / QtActivity I / dalvikvm(4074):at dalvik.system.NativeStart.run(本机方法)I / dalvikvm(4074):导致 作者:I / dalvikvm(4074):java.lang.ClassNotFoundException:没找到 路径上的“org.qtproject.qt5.android.bindings.QtActivity”类: DexPathList [[directory“。”],nativeLibraryDirectories = [/ system / lib]]