@Override public void onCreate(Bundle savedInstanceState){
  super.onCreate(savedInstanceState);
  mHandler=new Handler();
  setContentView(R.layout.voice_recognition);
  Button speakButton=(Button)findViewById(R.id.btn_speak);
  mList=(ListView)findViewById(R.id.list);
  mSupportedLanguageView=(Spinner)findViewById(R.id.supported_languages);
  PackageManager pm=getPackageManager();
  List<ResolveInfo> activities=pm.queryIntentActivities(new Intent(RecognizerIntent.ACTION_RECOGNIZE_SPEECH),0);
  if (activities.size() != 0) {
    speakButton.setOnClickListener(this);
  }
 else {
    speakButton.setEnabled(false);
    speakButton.setText("Recognizer not present");
  }
  refreshVoiceSettings();
}

@ Override public void onCreate ( Bundle savedInstanceState ) { super . onCreate ( savedInstanceState ) ; mHandler = new Handler ( ) ; setContentView ( R . layout . voice_recognition ) ; Button speakButton = ( Button ) findViewById ( R . id . btn_speak ) ; mList = ( ListView ) findViewById ( R . id . list ) ; mSupportedLanguageView = ( Spinner ) findViewById ( R . id . supported_languages ) ; PackageManager pm = getPackageManager ( ) ; List < ResolveInfo > activities = pm . queryIntentActivities ( new Intent ( RecognizerIntent . ACTION_RECOGNIZE_SPEECH ) , 0 ) ; if ( activities . size ( ) != 0 ) { speakButton . setOnClickListener ( this ) ; } else { speakButton . setEnabled ( false ) ; speakButton . setText ( "Recognizer not present" ) ; } refreshVoiceSettings ( ) ; }
called with the activity is first created .
