Search code examples
androidtitaniumappceleratorappcelerator-mobiletitanium-mobile

getStringArrayListExtra on Intent in Titanium (Appcelerator)


In order to use the speech recognition intent on Android, I need to be able to call getStringArrayListExtra on the intent in the activity result callback. Unfortunately, it looks like Titanium doesn't have a wrapper for this method in its Intent class. Does anyone know how I can go about getting this data despite this method not existing?

Here's my code:

  var intent = Ti.Android.createIntent({
    action: FOTT.VoiceRecognizer.ACTION_RECOGNIZE_SPEECH
  });

  /* ...snip... */

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

Solution

  • It turns out Titanium's Intent Proxy does not include a wrapper for this method. As such, I wrote a custom module to solve the problem.