QT 5.6 qml and android gallery.



  • Hello,

    I would like to know if the Android gallery should pop up when I make a c++ call to java through jni?

    void hulk::onipa()
    {
    
        selectedFileName = "#";
        QAndroidJniObject::callStaticMethod<void>("org/me/project/Qtandroidgallery",
                                                  "openAnImage",
                                                  "()V");
    }
    
    

    and the Java file is

        private static Qtandroidgallery m_instance;
    
        public Qtandroidgallery()
        {
            m_instance = this;
        }
    
        static void openAnImage()
        {
            m_instance.dispatchOpenGallery();
        }
        private void dispatchOpenGallery()
        {
            Intent intent = new Intent(Intent.ACTION_PICK);
            intent.setType("*/*");
    
            startActivityForResult(intent, 1);
    
        }
    

    The c++ function is called from QML.

    So, should the gallery show itself when startActivityForResult is called?

    Thanks


  • Qt Champions 2016

    Since you have already written the program. Why don't you just test it by yourself...?

    I don't know will your code works. Generally speaking, it is supposed to start another activity when startActivityForResult is called. However, it will show another dialog if there has multiple choice of activity available.

    But seem that it has missed a parameter in Intent construction in compared with regular example code for picking image in Android.

    Reference: A proven working image picking for Qt in Android:

    quickandroid/ImagePicker.java at master · benlau/quickandroid


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.