0

I followed the example from this site to eliminate the issues with static vs non static methods.

public static void startVoiceRecognitionActivity() {
  Log.d("Buttons","Start voice called in buttons");         

  Buttons demo = new Buttons();
  Intent intent = new Intent(RecognizerIntent.ACTION_RECOGNIZE_SPEECH);
  intent.putExtra(RecognizerIntent.EXTRA_LANGUAGE_MODEL,
        RecognizerIntent.LANGUAGE_MODEL_FREE_FORM);
  intent.putExtra(RecognizerIntent.EXTRA_PROMPT, "Voice recognition Demo...");

  Log.d("Buttons","Intent to start the command is:  "  +intent);
  demo.startActivityForResult(intent,VOICE_RECOGNITION_REQUEST_CODE);           
}

This code works in the main activity but the demo.startActivityForResult(intent,VOICE_RECOGNITION_REQUEST_CODE); generates the following error in the "Buttons" service class:

The method startActivityForResult(Intent, int) is undefined for the type Buttons

Can anyone clue me into what I'm doing wrong?

Thanks!

yorkw
  • 40,926
  • 10
  • 117
  • 130
Loren Zimmer
  • 482
  • 1
  • 6
  • 29

1 Answers1

0

Can't really answer this without knowing more about the Buttons class... Is Buttons an Activity or does it otherwise have a Context? If not, there's your problem. See this question.

Community
  • 1
  • 1
Andy Harris
  • 928
  • 5
  • 10
  • The original problem started with this thread: [link](http://stackoverflow.com/questions/11832635/android-service-to-start-activity-not-reacting-like-i-think-it-should). I couldn't get the activity to start like I need it to. So I thought I would create a service to enable calling the methods while the main activity is not shown on the display. Is my thought process logical? – Loren Zimmer Aug 16 '12 at 02:03