Titanium Community Questions & Answer Archive

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

Module intended to return string array; instead returning [Ljava.lang.Object;@445b4e90

I'm creating a module that is intended to return a string array. I've simplified it as such:

@Kroll.method
public String[] getStringArrayListExtra(final IntentProxy intentProxy, final String name) {
    if (DBG) {
        Log.d(LCAT, "getStringArrayListExtra called with name:" + name);
    }

    final ArrayList<String> list = intentProxy.getIntent().getStringArrayListExtra(name);

    // TEMP DEBUG OUTPUT THE ARRAY VALUES
    final StringBuilder builder = new StringBuilder();
    for (final String str : list) {
        builder.append('[').append(str).append("] ");
    }
    Log.d(LCAT, "getStringArrayListExtra contains \"" + list.size() + "\" items: " + builder.toString());

    return list != null ? list.toArray(new String[list.size()]) : null;
}

The actual implementation is the following:

Ti.Android.currentActivity.startActivityForResult(intent, function(event) {
  if (event.resultCode == Ti.Android.RESULT_OK) {
    var results = intentModule.getStringArrayListExtra(event.intent, "android.speech.extra.RESULTS");
    console.log(results);
  }
});

On the Java debug side of things, I'm getting results as expected such as:

> getStringArrayListExtra contains "1" items: [milk]

However, on the JavaScript side of things, I'm getting the raw Java Object:

> [Ljava.lang.Object;@445b4e90

Is there some special casting I need to do in my module to convert my String array to another format before returning? What am I doing wrong?

— asked November 17th 2011 by Matt Huggins
  • array
  • module
  • return
1 Comment
  • Ugh, sorry about the formatting of quotes, brackets, etc…not sure if I did something wrong, or if the site has a poor parser.

    — commented November 17th 2011 by Matt Huggins

1 Answer

  • Nevermind, I'm a moron. I just needed to treat the object as an array (e.g.: calling results.length or results[0] as one normally would).

    — answered November 17th 2011 by Matt Huggins
    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.