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 8788163
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T22:05:53+00:00 2026-06-13T22:05:53+00:00

In my app, am using SpeechRecognizer directly. I destroy SpeechRecognizer onPause of the Activity

  • 0

In my app, am using SpeechRecognizer directly. I destroy SpeechRecognizer onPause of the Activity and I recreate it in onResume method as below …

public class NoUISpeechActivity extends Activity {

protected static final String CLASS_TAG = "NoUISpeechActivity";
private SpeechRecognizer sr;


@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_no_uispeech);

    sr = getSpeechRecognizer();
}

@Override
protected void onPause() {

    Log.i(CLASS_TAG, "on pause called");
    if(sr!=null){
        sr.stopListening();
        sr.cancel();
        sr.destroy();       

    }

    super.onPause();
}


@Override
protected void onResume() {

    Log.i(CLASS_TAG, "on resume called");       

    sr = getSpeechRecognizer();

    super.onResume();
}

....

private SpeechRecognizer getSpeechRecognizer() {
    if(sr == null){
        sr = SpeechRecognizer.createSpeechRecognizer(getApplicationContext());
        CustomRecognizerListner listner = new CustomRecognizerListner();
        listner.setOnListeningCallback(new OnListeningCallbackImp());
        sr.setRecognitionListener(listner);
    }
    return sr;
}
}

When the app is installed via eclipse for the first time, SpeechRecognition service is called and recognition happens properly.But when app comes back from pause, if i try to recognize speech i get “SpeechRecognition: not connect to recognition service” error

What am i doing wrong ?

  • 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-06-13T22:05:54+00:00Added an answer on June 13, 2026 at 10:05 pm

    I found the reason to the problem. In onPause method though SpeechRecognition.destroy() method is called, I guess it just detaches the service but the object sr will be pointing to some instance and it wont be null. Resetting the object sr to null would solve the problem.

    Not destroying the SpeechRecognition object in onPause method would block other apps from using SpeechRecognition service

    @Override
    protected void onPause() {
    
        Log.i(CLASS_TAG, "on pause called");
        if(sr!=null){
            sr.stopListening();
            sr.cancel();
            sr.destroy();              
    
        }
        sr = null;
    
        super.onPause();
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

When testing my app using Instruments -> Activity Monitor, I'm seeing a difference in
I created my app using StoryBoard. Then, I added objective-c class to have .h
I am using mapview in my android app using the class com.google.android.maps I wont
I am developing an app using jquery mobile and last issue to be solved
I am creating an app using iOS 5 SDK. I managed to push views
I am developing a app using Monodroid (C#) and wanted to some good looking
I have a Sinatra app using Rack::Session::Cookie use Rack::Session::Cookie, :key => 'my.key', :path =>
I have a PhoneGap App using jQuery Mobile. At a certain page, I cannot
I built my app using Grails 2.0.4 and tested it in Jetty. In Jetty
I'm developing an app using Silverlight control for Bing Maps . User can search

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.