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,
    Java code -

    Intent capture_image_intent = new Intent();
    startActivityForResult(capture_image_intent, 101);

    I written this java code in Qt by using Qandroidjniobject. This is given below,
    Qt code -

    QAndroidJniObject ACTION_CAPTURE = QAndroidJniObject::fromString("android.provider.MediaStore.ACTION_IMAGE_CAPTURE");
                QAndroidJniObject intent("android/content/Intent");
                if (ACTION_CAPTURE.isValid() && intent.isValid())
                    intent.callObjectMethod("setAction", "(Ljava/lang/String;)Landroid/content/Intent;", ACTION_CAPTURE.object<jstring>());
                    QtAndroid::startActivity(intent.object<jobject>(), 101, this);
                    qDebug() << "OK";
                    qDebug() << "ERROR";

    Now, my question is by using above qt code my app cannot launch Camera. So, please help me for finding what is the problem?

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

    For launching camera by using intent code is given below,

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