androidc++qtcameraqandroidjniobject

Qt and Android - How to launch camera by using Qandroidjniobject


I am new in Qt android app development. I want to open camera and take picture and get the path of image by using QtAndroid, and JNIObject.

For example,

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

I want to launch camera in my Qt android app by using Qandroidjniobject. So, please help me to write a code in qt.


Solution

  • I solved this above problem in Qt by using Qandroidjniobject.

    For launching camera by using intent code is given below,

    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);