Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 5954575
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T17:59:26+00:00 2026-05-22T17:59:26+00:00

I’m using the Android Speech Recognition intent but I would like to know what

  • 0

I’m using the Android Speech Recognition intent but I would like to know what language the user has set to do the recognition. The docs on the RecognizerIntent imply that you can get this from the intent data, but I keep getting null.

Are these values on useable when calling the Intent? Is there another way to get this data?

Here’s how I call the intent:

private void startVoiceRecognitionActivity() {
    Logger.i(AppConfig.LOGTAG, "startVoiceRecognitionActivity");
    Intent intent = new Intent(RecognizerIntent.ACTION_RECOGNIZE_SPEECH);
    intent.putExtra(RecognizerIntent.EXTRA_PROMPT, "speech recognition demo");
    startActivityForResult(intent, VOICE_RECOGNITION_REQUEST_CODE);
}

And I get the results like this:

/**
 * Handle the results from the recognition activity.
 */
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
  if (requestCode == VOICE_RECOGNITION_REQUEST_CODE && resultCode == RESULT_OK) {

     Logger.i(AppConfig.LOGTAG, "EXTRA_LANGUAGE = "+data.getStringExtra(RecognizerIntent.EXTRA_LANGUAGE));
     Logger.i(AppConfig.LOGTAG, "EXTRA_LANGUAGE_MODEL = "+data.getStringExtra(RecognizerIntent.EXTRA_LANGUAGE_MODEL));
     Logger.i(AppConfig.LOGTAG, "EXTRA_LANGUAGE_PREFERENCE = "+data.getStringExtra(RecognizerIntent.EXTRA_LANGUAGE_PREFERENCE));

  } else {
     Toast.makeText(getApplicationContext(), "Voice recognition failed.", Toast.LENGTH_LONG).show();
  }
  super.onActivityResult(requestCode, resultCode, data);
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-22T17:59:26+00:00Added an answer on May 22, 2026 at 5:59 pm

    It seems that you need to send a broadcast to ask what language is configured in the voice recognition. So, the sequence is

    • Call the ACTION_RECOGNIZE_SPEECH Intent.
    • On receipt of the response to this Intent, broadcast the ACTION_GET_LANGUAGE_DETAILS Intent.
    • On receipt of the respone to this broadcast request you can then process the text that the original Intent returned.

    Code below:

    /**
     * Handle the results from the recognition activity. First thing to do is 
     * to get the language...
     */
    @Override
    protected void onActivityResult(int requestCode, int resultCode, Intent data) {
      if (requestCode == VOICE_RECOGNITION_REQUEST_CODE && resultCode == RESULT_OK) {
    
         Intent intent = new Intent(RecognizerIntent.ACTION_GET_LANGUAGE_DETAILS);
         LangBroadcastReceiver myBroadcastReceiver = new LangBroadcastReceiver(this, data.getStringArrayListExtra(RecognizerIntent.EXTRA_RESULTS));
         sendOrderedBroadcast(intent, null, myBroadcastReceiver, null, Activity.RESULT_OK, null, null);
    
      } else {
         Toast.makeText(getApplicationContext(), "Voice recognition failed.", Toast.LENGTH_LONG).show();
      }
      super.onActivityResult(requestCode, resultCode, data);
    }
    
    
    
    /**
     * After a voice recognition is performed, need to sent a broadcast to
     * request the language used. This BroadcastReceiver gets the response and
     * then processes the original recognisedText from the
     * ACTION_RECOGNIZE_SPEECH Intent.
     * 
     */
    public class LangBroadcastReceiver extends BroadcastReceiver {
      ArrayList<String> recognisedText;
      Activity parentActivity;
    
      /**
       * Store these for later use...
       * @param activity
       * @param arrayList
       */
      LangBroadcastReceiver(Activity activity, ArrayList<String> arrayList) {
         recognisedText = arrayList;
         parentActivity = activity;
      }
    
      @Override
      public void onReceive(Context context, Intent intent) {
         Bundle results = getResultExtras(true);
         String lang = results.getString(RecognizerIntent.EXTRA_LANGUAGE_PREFERENCE);
         Log.d(AppConfig.LOGTAG, "MyBroadcastReceiver: Got 'EXTRA_LANGUAGE_PREFERENCE' = " + lang);
         // now handle the recognisedText with the known language.
      }
    

    }

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

That's pretty much it. I'm using Nokogiri to scrape a web page what has
I want to count how many characters a certain string has in PHP, but
I would like to count the length of a string with PHP. The string
I've got a string that has curly quotes in it. I'd like to replace
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I need to clean up various Word 'smart' characters in user input, including but
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I'm new to using the Perl treebuilder module for HTML parsing and can't figure
link Im having trouble converting the html entites into html characters, (&# 8217;) i
For some reason, after submitting a string like this Jack’s Spindle from a text

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.