Qt 和 Android - 如何使用 Qandroidjniobject 启动相机



我是Qt android应用程序开发的新手。我想打开相机拍照,并使用QtAndroid和JNIObject获取图像的路径。

例如

Intent capture_image_intent = new Intent();
capture_image_intent.setAction(MediaStore.ACTION_IMAGE_CAPTURE);
startActivityForResult(capture_image_intent, 101);

我想使用 Qandroidjniobject 在我的 Qt android 应用程序中启动相机。所以,请帮我用qt写一段代码。

我通过使用Qandroidjniobject在Qt中解决了上述问题。

下面给出了使用意图代码启动相机,

QAndroidJniObject ACTION_IMAGE_CAPTURE = 
QAndroidJniObject::getStaticObjectField("android/provider/MediaStore", 
"ACTION_IMAGE_CAPTURE", "Ljava/lang/String;");
QAndroidJniObject intent("android/content/Intent", "(Ljava/lang/String;)V", 
ACTION_IMAGE_CAPTURE.object<jstring>());
QtAndroid::startActivity(intent.object<jobject>(), 101, this);

相关内容

  • 没有找到相关文章

最新更新