Qt Open Android Album Select a picture and get the local path to the picture

Source: Internet
Author: User

Qt Open Android Album Select a picture and get the local path to the picture

The steps are as follows:

  1. 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;");
  2. After the user selects a picture in the System album, it C++ gets the address of the picture in the code content .

  3. 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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.