Brandon O'Rourke
Brandon O'Rourke

Reputation: 24625

Extending Android's Voice Search app

Is it possible to extend the Voice Search app? I know I can add a button in my own app to launch the voice recognition dialog, but I was wondering if I could extend the voice search app that launches automatically when you long press the physical "search" key.

send text to [contact] [message]
listen to [artist/song/album]
call [business]
call [contact]
send email to [contact] [message]
go to [website]
note to self [note]
navigate to [location/business name]
directions to [location/business name]
map of [location]

I'd basically like to add my own action to the above list.

Is this possible or will I have to create my own?

Upvotes: 10

Views: 1127

Answers (2)

shivampip
shivampip

Reputation: 2144

A simple method to Handle Voice Search

Step 1 Call this method on button click

public void startVoiceRecognition() {
    Intent intent = new Intent("android.speech.action.RECOGNIZE_SPEECH");
    intent.putExtra("android.speech.extra.LANGUAGE_MODEL", "free_form");
    intent.putExtra("android.speech.extra.PROMPT", "Speak Now");
    this.mContainerActivity.startActivityForResult(intent, 3012);
}

Step 2 Override onActivityResult method

@ Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
    if (requestCode == 3012 && resultCode == RESULT_OK) {
        ArrayList < String > matches = data.getStringArrayListExtra("android.speech.extra.RESULTS");
        String result= matches.get(0);
        //Consume result 
        edittext.setText(result);
    }
}

Thats all, DONE

Upvotes: 0

Rohan Singh
Rohan Singh

Reputation: 21465

In a word, no. The app doesn't have the extension points you are looking for. You would have to write your own app entirely, which is something that others have done.

Upvotes: 2

Related Questions