intent.getData( ) method is returning null in onActivityResult( ) method. (using NFI to access the images from Android Gallery)

This thread was migrated from an old forum. It may contain information that are no longer valid. For further assistance, please post a new question or open a support ticket from the Customer Support portal.

Hi Team,

I am opening Android images Gallery using NFI, After selecting images onActivityResult( ) method is triggered but I am getting null value in intent.getData( ) function.

following is the code :

define({

openGallery:function( )

{

var KonyMain = java.import('com.konylabs.android.KonyMain');

var context = KonyMain.getActivityContext();

var MainClass = java.newClass("MainClass","java.lang.Object",["com.konylabs.ffi.ActivityResultListener"],{

onActivityResult : function(requestCode,resultCode,intent) {

if(resultCode==KonyMain.RESULT_OK){

try {

alert(intent.getData());

} catch (exception) {

alert(exception.message);

}

}else{

var toast2 = new kony.ui.Toast({"text":"Images selection Fail","duration":2000});

toast2.show();

}

}

});

var intentClassObj = new MainClass();

var Intent = java.import('android.content.Intent');

var i = new Intent( );

i.setAction(Intent.ACTION_GET_CONTENT);

i.setType("image/*");

i.putExtra(Intent.EXTRA_ALLOW_MULTIPLE, true);

context.registerActivityResultListener(123, intentClassObj);

context.startActivityForResult(i,123);

},

});

Thanks

Hi,

I am able to get the selected image URI in the intent.getData() using visualizer 8.3.x version and Android 8.0 with the code that you mentioned.

alert(intent.getData())//provides native object

alert(JSON.stringify(intent.getData()+""));//provides me the URI

PFA screenshot for reference.

Please let us know which version of visualizer are you using?

Thanks