语言

Menu
Sites
Language
reply.length is always 1 no matter how many images are chosen (selection_mode , multiple , images, ApplicationControl)
I'm struggling to get choosen image url paths, but reply.length is always 1 no matter how many images are chosen.
How to solve the issue?
 
var array = [];
 
try {
    var appControl = new tizen.ApplicationControl(
        "http://tizen.org/appcontrol/operation/pick",
        null,
        "image/*",
        null, [new tizen.ApplicationControlData("http://tizen.org/appcontrol/data/selection_mode", ["multiple"])]);
 
    var appControlReplyCallback = {
        onsuccess: function(reply) {
            for (var i = 0; i < reply.length; i++) {
              if (reply[i].key === "http://tizen.org/appcontrol/data/selected") {
                   array.push(reply[i].value[0]);
               }
            }
        },
        onfailure: function() {
            console.log("The launch application control failed");
        }
    };
    tizen.application.launchAppControl(
        appControl,
        null,
        function() {
            console.log("launch application control succeed");
        },
        function(e) {
            console.log("launch application control failed. reason: " + e.message);
        },
        appControlReplyCallback
    );
} catch (e) {
    alert("Error " + e.name + " : " + e.message);
}
编辑者为: Anonymous 03 5月, 2019
查看选择的答案

响应

1 回复
Mark as answer

I found out the solution by myself :D

I thought that the list of chosen images was in reply array but it turned out reply array contained another array of chosen images reply[i].value[i] :D

So reply[i].value[0] is the first image, reply[i].value[1] is the second one and so on!

reply[i].value.length returns the number of chosen images!