언어 설정

Menu
Sites
Language
How to launch gallery app and retrieve which file is selected?

 

Can you provide a sample application ?
i am a beginner and have no more ideas.
Can you help me?
Thanks in Advance.

Edited by: Brock Boland on 17 3월, 2014 Reason: Paragraph tags added automatically from tizen_format_fix module.

Responses

10 댓글
Lakshmi Grandhi
Hi anfas, I am working on the sample application, will provide once done Thanks Lakshmi
Lakshmi Grandhi
Hi anfas, As specified in forum posthttps://developer.tizen.org/forums/web-application-development/how-launch-gallery-app-and-retrieve-which-file-selected, copy the below code and place in your main.js file //Initialize function var init = function () { $('div[data-role="page"]:first .ui-btn-back').bind("click", function(event) { var currentApp = tizen.application.getCurrentApplication(); currentApp.exit(); }); // TODO:: Do your initialization job console.log("init() called"); var appControl = new tizen.ApplicationControl("http://tizen.org/appcontrol/operation/pick", null, "image/*"); tizen.application.launchAppControl(appControl, null, function(){console.log("launch appControl succeeded");}, function(e){console.log("launch appControl failed. Reason: " + e.name);}, appControlReplyCB); var appControlReplyCB = { onsuccess: function(data) { for (var i=0; i < data.length; i++) { if(data[i].key == "http://tizen.org/appcontrol/data/selected") { console.log("Stored at: " + data[i].value[0]); } } }, onfailure: function() { console.log('Service returned with failure'); } }; }; $(document).bind('pageinit', init); and run it will launch gallery application then on selecting any file, console.log("Stored at: " + data[i].value[0]); this statement will print the file selected. Note: In Emulator always Gallery App is launched and it show no images availble. Kindly test it on developer device.
Hi Lakshmi, I've tested your sample in my application. The gallery launches fine but when I pick an image I just get back to my app without the selected file being logged. Regards, Enoal
Lakshmi Grandhi
Hi enoal, Can you check, whether this callback called with data onsuccess: function(data) { for (var i=0; i < data.length; i++) { if(data[i].key == "http://tizen.org/appcontrol/data/selected") { console.log("Stored at: " + data[i].value[0]); } }
I'm using the following code :
//Initialize function
var init = function() {
  $( 'div[data-role="page"]:first .ui-btn-back' ).bind( "click", function( event ) {
    var currentApp = tizen.application.getCurrentApplication();
    currentApp.exit();
  } );

  // TODO:: Do your initialization job
  console.log( "init() called" );
  var appControl = new tizen.ApplicationControl( "http://tizen.org/appcontrol/operation/pick", null, "image/*" );
  tizen.application.launchAppControl( appControl, null, function() {
    console.log( "launch appControl succeeded" );
  }, function( e ) {
    console.log( "launch appControl failed. Reason: " + e.name );
  }, appControlReplyCB );

  var appControlReplyCB = {
  onsuccess : function( data ) {
    console.log( 'Service returned with success' );
    for ( var i = 0; i < data.length; i++ ) {
      if ( data[ i ].key == "http://tizen.org/appcontrol/data/selected" ) {
        console.log( "Stored at: " + data[ i ].value[ 0 ] );
      }
    }
  },
  onfailure : function() {
    console.log( 'Service returned with failure' );
  }
  };
};
$( document ).bind( 'pageinit', init );
And all I get in the console is :
wgt/js/main.js (9) :init() called
wgt/js/main.js (12) :launch appControl succeeded
Got it! You have to declare appControlReplyCB before calling launchAppControl. Regards, Enoal
Now that I get the response how do I access the selected file? I can use
tizen.filesystem.resolve( "images" ..... )
to access all the files under "images" in the gallery but how do I access the one that were taken by the camera? They are under
/opt/usr/media/Camera/
but I can't find the proper virtual root to access them. Regards, Enoal
Lakshmi Grandhi
Hi enoal, to get the images files under Camera folder you have to use camera folder id "7bbfe1cb-79dc-4477-b76c-086add396af1" on find API. gManager.find(onFindSuccess, onFindError, "7bbfe1cb-79dc-4477-b76c-086add396af1" , mediaType == "ALL" ? null : new tizen.AttributeFilter("type", "EXACTLY", "IMAGE"), new tizen.SortMode("title", "ASC"));
luca mezzalira
is there a method to select more than one image from the gallery?! for example activating the multi_pick option (if it exists!?) thanks
Vineet Tiwari
Hii Currently there is no such support