Search Results

Search found 1 results on 1 pages for 'user1007522'.

Page 1/1 | 1 

  • Show Alertdialog and use vibrator

    - by user1007522
    I'm having a class that implements RecognitionListener like this: public class listener implements RecognitionListener I wanted to show a alertdialog and use the vibrator but this isn't possible because I need to provide a context what I don't have. My alertdialog code was like this: new AlertDialog.Builder(this) .setTitle("dd") .setMessage("aa") .setNeutralButton("Ok", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { } }) .show(); But the AlertDialog.Builder(this) wants a context, the same problem with my vibrator code: v = (Vibrator) getSystemService(Context.VIBRATOR_SERVICE); The getSystemService method isn't available. My code that starts the class: sr = SpeechRecognizer.createSpeechRecognizer(this); sr.setRecognitionListener(new listener()); Intent intent = new Intent(RecognizerIntent.ACTION_RECOGNIZE_SPEECH); intent.putExtra(RecognizerIntent.EXTRA_LANGUAGE_MODEL,RecognizerIntent.LANGUAGE_MODEL_FREE_FORM); intent.putExtra(RecognizerIntent.EXTRA_CALLING_PACKAGE,"voice.recognition.test"); intent.putExtra(RecognizerIntent.EXTRA_MAX_RESULTS,5); sr.startListening(intent); Whats the best way to solve this?

    Read the article

1