Qt Open Android Album Select a picture and get the local path to the picture
The steps are as follows:
By Intent
opening the Android system album.
It is recommended to use QAndroidJniObject::getStaticObjectField
get static fields.
QAndroidJniObject action = QAndroidJniObject::getStaticObjectField( "android/content/Intent", "ACTION_GET_CONTENT", "Ljava/lang/String;");
After the user selects a picture in the System album, it C++
gets the address of the picture in the code content
.
The local path of the picture is drawn through the query.
URI uri = Data. GetData();String[] proj = {Mediastore. Images. Media. DATA};Cursor actualimagecursor = managedquery (uri,proj,null,null,null);int actual_image_column_index = Actualimagecursor. Getcolumnindexorthrow(Mediastore. Images. Media. DATA);Actualimagecursor. Movetofirst();String Img_path = Actualimagecursor. getString(Actual_image_column_index);File File = new file (Img_path);
Turn the appeal's Java code into C + + code. Refer to Qt and Android Gallery-mediastore using Qandroidjniobject.
Example download Callnativegallery, you can also choose to fork this project.
Resources:
Qt and Android Gallery-mediastore using Qandroidjniobject
How to OPEN ANDROID IMAGE GALLERY in QT
Android implements URI to get the real path converted to file method
Thread:converting Qandroidjniobject to jobjectarray:most elements is null!
How to return a array from JNI to Java?
Qt Open Android Album Select a picture and get the local path to the picture