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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T10:43:36+00:00 2026-05-31T10:43:36+00:00

I put speech function into a new class called voiceAssistants, however, when i start

  • 0

I put speech function into a new class called voiceAssistants, however, when i start it, it always give me an null pointer exception error.

voice Assistants:

public class VoiceAssistants {
    private static final int VOICE_RECOGNITION_REQUEST_CODE = 1234;
    private static VoiceActivityHelper voiceAssistants;
    public VoiceAssistants(){
        voiceAssistants = new VoiceActivityHelper();
    }
    /**
     * Start voice input
     */
    public void starVoiceAssistants(){
        this.voiceAssistants.startVoiceRecognitionActivity();
    }

    private static class VoiceActivityHelper extends Activity {

        private static ArrayList<String> matches;

        public ArrayList<String> getResultSet(){
            return matches;
        }

        private void startVoiceRecognitionActivity() {
            Intent intent = new Intent(RecognizerIntent.ACTION_RECOGNIZE_SPEECH);
        intent.putExtra(RecognizerIntent.EXTRA_LANGUAGE_MODEL,
                RecognizerIntent.LANGUAGE_MODEL_FREE_FORM);
        intent.putExtra(RecognizerIntent.EXTRA_LANGUAGE, String.format(
                "%s_%s", Locale.getDefault().getLanguage(), Locale
                        .getDefault().getCountry()));
        intent.putExtra(RecognizerIntent.EXTRA_PROMPT,
                "Speech recognition demo");
                        //error happen here!!!
            startActivityForResult(intent, VOICE_RECOGNITION_REQUEST_CODE);
        }
    }
}

But when I put it into normal activity that generated by new project, it won’t tall any error.
log infos:

E/AndroidRuntime(22769): java.lang.NullPointerException
E/AndroidRuntime(22769):
at android.app.Activity.startActivityForResult(Activity.java:2827)
E/AndroidRuntime(22769):    
at panda.com.db.VoiceAssistants$VoiceActivityHelper.startVoiceRecognitionActivity(VoiceAssistants.java:56)
E/AndroidRuntime(22769):    
at panda.com.db.VoiceAssistants$VoiceActivityHelper.access$1(VoiceAssistants.java:47)
E/AndroidRuntime(22769):    
at panda.com.db.VoiceAssistants.starVoiceAssistants(VoiceAssistants.java:24)

plz help, thank you!!

  • 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-31T10:43:37+00:00Added an answer on May 31, 2026 at 10:43 am

    You’re calling startActivityForResult() but this isn’t an Activity. Your Activity is a private inner class that no one else has access to.

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

Sidebar

Related Questions

Put your foot inside the boots of an expert developer that is new to
I put together a little jquery function to zoom in and out of an
I put an asp.net hiddenfield into one of my pages. I couldn't access it
put the aspxgridview into aspxpopup control. when peform filter on the aspxgridview the row
Put simply: I want the following code to print sub: Element e = new
I put the bottom jquery into a .js file and then I imported it
I need to classify words into their parts of speech. Like a verb, a
Put another way, you create a new kind of object by making a package
i put all the value from A,B,E,F,G,I columns to a new columns Q. Can
I put the following method in my application.js file. var formhandler = function() {

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.