What I tried to do:
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
ArrayList<String> voiceResults = getIntent().getExtras()
.getStringArrayList(RecognizerIntent.EXTRA_RESULTS);
Card ShowDataCard = new Card(this);
ShowDataCard.setText(voiceResults);
View ShowDataCardView = ShowDataCard.toView();
setContentView(ShowDataCardView);
}
Failed work-around:
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
String voiceResults = getIntent().getExtras()
.getString(RecognizerIntent.EXTRA_RESULTS);
Card ShowDataCard = new Card(this);
ShowDataCard.setText(voiceResults);
View ShowDataCardView = ShowDataCard.toView();
setContentView(ShowDataCardView);
}
The String voiceResults is a failed workaround to the fact I cannot .setText to an arraylist string
Actual voice recognition code:
ArrayList<String> voiceResults = getIntent().getExtras()
.getStringArrayList(RecognizerIntent.EXTRA_RESULTS);
Basically I am trying to save this voice recognition (going to use SharedPreferences) but for some reason it is an arraylist string and not just a string. Anybody know how to save it as a String? (or publish an activity with an arraylist string)
Since the results are an ArrayList
of strings, you should check that the size()
of the list is at least 1 and then call voiceResults.get(0)
to get the string.