• After 15+ years, we've made a big change: Android Forums is now Early Bird Club. Learn more here.

Voice Recognition

cris168

Lurker
Mar 3, 2012
2
0
Hi,


Scenario:
I want the voice recognition to be part in background process. I can execute background processing (NO problem). And I want to call a voice recognition. The code below runs perfect. But I don't know how to include it on background process. (Note: I've used service in to create a background process).

Problem:
How can I run this code below in background processing ?

Intent i = new Intent(RecognizerIntent.ACTION_RECOGNIZE_SPEECH);
i.putExtra(RecognizerIntent.EXTRA_LANGUAGE_MODEL, RecognizerIntent.LANGUAGE_MODEL_FREE_FORM);
i.putExtra(RecognizerIntent.EXTRA_PROMPT, "Speak ...");
startActivityForResult(i,check);

@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
// TODO Auto-generated method stub

if (requestCode == 1234 && resultCode == RESULT_OK ) {
ArrayList<String> results = data.getStringArrayListExtra(RecognizerIntent.EXTRA_RESULTS);
lv.setAdapter(new ArrayAdapter<String>(this,android.R.layout.simple_list_item_1,results));
}

super.onActivityResult(requestCode, resultCode, data);
}

Please help...

Thanks,
Cris
 

BEST TECH IN 2023

We've been tracking upcoming products and ranking the best tech since 2007. Thanks for trusting our opinion: we get rewarded through affiliate links that earn us a commission and we invite you to learn more about us.

Smartphones