Titanium Community Questions & Answer Archive

We felt that 6+ years of knowledge should not die so this is the Titanium Community Questions & Answer Archive

Pass array from Titanium to android java

Can anyone show me how to pass array from titanium (javascript) to android (java)?

###Example:

var myArray = new Array();
myArray[0]="example1";
myArray[1]="example2";
myArray[2]="example3";
— asked November 10th 2010 by Channara Lay
  • titaniumandroid
1 Comment
  • I think you'll need to provide more info on the use case for anyone to help - what are you trying to accomplish specifically? Are you trying to write Java code to be invoked by JavaScript? Generally speaking, the Titanium API doesn't allow you to pass anything directly to Java code - the Titanium APIs proxy native Java methods which are invoked indirectly after a Titanium function is called in JavaScript.

    — commented November 10th 2010 by Kevin Whinnery

2 Answers

  • An array of what? if is is data that can be converted to a string of some sort, I would suggest using JSON to pass the data between the two

    — answered November 10th 2010 by Aaron Saunders
    permalink
    0 Comments
  • var myArray = new Array();
    myArray={'data1','data2','data3'};

    this way to write in your coding, i think this is write way to declaration

    — answered January 11th 2012 by Mritunjay Singh
    permalink
    0 Comments
The ownership of individual contributions to this community generated content is retained by the authors of their contributions.
All trademarks remain the property of the respective owner.