List of usage examples for android.speech RecognizerIntent ACTION_RECOGNIZE_SPEECH
String ACTION_RECOGNIZE_SPEECH
To view the source code for android.speech RecognizerIntent ACTION_RECOGNIZE_SPEECH.
Click Source Link
From source file:com.eveningoutpost.dexdrip.Home.java
public void promptSpeechNoteInput(View abc) { if (recognitionRunning) return;// ww w . j a v a 2 s. c o m recognitionRunning = true; Intent intent = new Intent(RecognizerIntent.ACTION_RECOGNIZE_SPEECH); intent.putExtra(RecognizerIntent.EXTRA_LANGUAGE_MODEL, RecognizerIntent.LANGUAGE_MODEL_FREE_FORM); intent.putExtra(RecognizerIntent.EXTRA_LANGUAGE, Locale.getDefault()); // intent.putExtra(RecognizerIntent.EXTRA_LANGUAGE, "en-US"); // debug voice intent.putExtra(RecognizerIntent.EXTRA_PROMPT, getString(R.string.speak_your_note_text)); try { startActivityForResult(intent, REQ_CODE_SPEECH_NOTE_INPUT); } catch (ActivityNotFoundException a) { Toast.makeText(getApplicationContext(), getString(R.string.speech_recognition_is_not_supported), Toast.LENGTH_LONG).show(); } }
From source file:com.wizardsofm.deskclock.alarms.AlarmActivity.java
public void startListening() { makeText(this, getResources().getString(R.string.prompt_voice_commands), Toast.LENGTH_SHORT).show(); speech = SpeechRecognizer.createSpeechRecognizer(this); speech.setRecognitionListener(this); intent = new Intent(RecognizerIntent.ACTION_RECOGNIZE_SPEECH); intent.putExtra(RecognizerIntent.EXTRA_LANGUAGE_PREFERENCE, "en"); intent.putExtra(RecognizerIntent.EXTRA_CALLING_PACKAGE, this.getPackageName()); // intent.putExtra("android.speech.extra.DICTATION_MODE", true); speech.startListening(intent);/*from w w w . j a v a2 s .c o m*/ resumeCounting = true; keepListening(); }
From source file:com.android.dialer.DialtactsFragment.java
@Override public void onClick(View view) { int i = view.getId(); if (i == R.id.floating_action_button) {// if (mListsFragment.getCurrentTabIndex() // == ListsFragment.TAB_INDEX_ALL_CONTACTS && !mInRegularSearch) { // DialerUtils.startActivityWithErrorToast( // this, // IntentUtil.getNewContactIntent(), // R.string.add_contact_not_available); // } else if (!mIsDialpadShown) { // mInCallDialpadUp = false; // showDialpadFragment(true); // } Log.d(TAG, " onClic mIsDialpadShown " + mIsDialpadShown); if (!mIsDialpadShown) { mInCallDialpadUp = false;/* ww w .j a v a 2 s. c o m*/ showDialpadFragment(true); } } else if (i == R.id.voice_search_button) { try { startActivityForResult(new Intent(RecognizerIntent.ACTION_RECOGNIZE_SPEECH), ACTIVITY_REQUEST_CODE_VOICE_SEARCH); } catch (ActivityNotFoundException e) { Toast.makeText(DialtactsFragment.this.getContext(), R.string.voice_search_not_available, Toast.LENGTH_SHORT).show(); } } else if (i == R.id.dialtacts_options_menu_button) { mOverflowMenu.show(); } else if (i == R.id.dialtacts_bottom_menu_button_call) { if (!mIsDialpadShown) { mInCallDialpadUp = false; showDialpadFragment(true); } else { if (TextUtils.isEmpty(mSearchQuery) || (mSmartDialSearchFragment != null && mSmartDialSearchFragment.isVisible() && mSmartDialSearchFragment.getAdapter().getCount() == 0)) { exitSearchUi(); } hideDialpadFragment(true, true); } } else if (i == R.id.actionbar_menu) { initCallLogSelectPopupWindow(); Log.e(TAG, " onClick actionbar_menu"); } else if (i == R.id.actionbar_name) { initCallLogSelectPopupWindow(); Log.e(TAG, " ---- onClick actionbarName ----"); } else if (i == R.id.actionbar_call_dialtacts_action_editer) { StringBuilder sb = new StringBuilder(""); if (mDialtactsActionBarController.getEditerText() .equals(getResources().getString(R.string.call_detail_editer))) { showMultipleEditer(); mDialtactsActionBarController.setEditerTxt(getString(R.string.call_delete_select_all)); } else if (mDialtactsActionBarController.getEditerText() .equals(getResources().getString(R.string.call_delete_select_all))) { mCalllogList.allSelectLog(true); mDialtactsActionBarController.setEditerTxt(getString(R.string.call_delete_cansel_all)); sb.append(mCalllogList.getSelectLogCount()).append("?"); mDialtactsActionBarController.setActionName(new String(sb)); } else if (mDialtactsActionBarController.getEditerText() .equals(getResources().getString(R.string.call_delete_cansel_all))) { mCalllogList.allSelectLog(false); mDialtactsActionBarController.setEditerTxt(getString(R.string.call_delete_select_all)); mDialtactsActionBarController.setActionName(getString(R.string.select_call_log)); } mFloatingActionButtonController.setVisible(false); mCalllogList.setmSelectCallLogImpl(mSeletectCallLogImpl); } else if (i == R.id.actionbar_call_dialtacts_action_cancel) { hideMultipleEditer(); } else if (i == R.id.dialtacts_bottom_menu_button_delete) { processDeleteBtn(); } else { Log.wtf(TAG, "Unexpected onClick event from " + view); } }
From source file:com.arlib.floatingsearchview.FloatingSearchView.java
private Intent createVoiceRecIntent(Activity activity, String hint) { Intent intent = new Intent(RecognizerIntent.ACTION_RECOGNIZE_SPEECH); intent.putExtra(RecognizerIntent.EXTRA_PROMPT, hint); intent.putExtra(RecognizerIntent.EXTRA_LANGUAGE_MODEL, RecognizerIntent.LANGUAGE_MODEL_FREE_FORM); intent.putExtra(RecognizerIntent.EXTRA_MAX_RESULTS, 1); return intent; }
From source file:com.android.dialer.DialtactsActivity.java
private void prepareVoiceSearchButton() { final Intent voiceIntent = new Intent(RecognizerIntent.ACTION_RECOGNIZE_SPEECH); if (canIntentBeHandled(voiceIntent)) { mVoiceSearchButton.setVisibility(View.VISIBLE); mVoiceSearchButton.setOnClickListener(this); } else {// w w w . ja v a2 s.com mVoiceSearchButton.setVisibility(View.GONE); } }
From source file:com.eveningoutpost.dexdrip.Home.java
/** * Showing google speech input dialog/*www. j a va2 s . co m*/ */ private void promptSpeechInput() { if (recognitionRunning) return; recognitionRunning = true; Intent intent = new Intent(RecognizerIntent.ACTION_RECOGNIZE_SPEECH); intent.putExtra(RecognizerIntent.EXTRA_LANGUAGE_MODEL, RecognizerIntent.LANGUAGE_MODEL_FREE_FORM); intent.putExtra(RecognizerIntent.EXTRA_LANGUAGE, Locale.getDefault()); // intent.putExtra(RecognizerIntent.EXTRA_LANGUAGE, "en-US"); // debug voice intent.putExtra(RecognizerIntent.EXTRA_PROMPT, getString(R.string.speak_your_treatment)); try { startActivityForResult(intent, REQ_CODE_SPEECH_INPUT); } catch (ActivityNotFoundException a) { Toast.makeText(getApplicationContext(), R.string.speech_recognition_is_not_supported, Toast.LENGTH_LONG) .show(); } }
From source file:com.google.android.apps.paco.ExperimentExecutorCustomRendering.java
public void startSpeechRecognition(SpeechRecognitionListener listener) { speechRecognitionListeners.add(listener); Intent intent = new Intent(RecognizerIntent.ACTION_RECOGNIZE_SPEECH); intent.putExtra(RecognizerIntent.EXTRA_LANGUAGE_MODEL, Locale.getDefault().getDisplayName()); try {/*w w w.j ava 2 s . c o m*/ startActivityForResult(intent, RESULT_SPEECH); } catch (ActivityNotFoundException a) { Toast t = Toast.makeText(getApplicationContext(), R.string.oops_your_device_doesn_t_support_speech_to_text, Toast.LENGTH_SHORT); t.show(); } }
From source file:radu.pidroid.Controller.java
public void startVoiceRecognition() { Intent intent = new Intent(RecognizerIntent.ACTION_RECOGNIZE_SPEECH); intent.putExtra(RecognizerIntent.EXTRA_LANGUAGE_MODEL, RecognizerIntent.LANGUAGE_MODEL_FREE_FORM); startActivityForResult(intent, SPEECH_RECOGNITION_REQUEST_CODE); }
From source file:com.android.dialer.DialtactsFragment.java
private void prepareVoiceSearchButton() { final Intent voiceIntent = new Intent(RecognizerIntent.ACTION_RECOGNIZE_SPEECH); boolean canBeHandled = canIntentBeHandled(voiceIntent); // if (canIntentBeHandled(voiceIntent)) { // mVoiceSearchButton.setVisibility(View.VISIBLE); // mVoiceSearchButton.setOnClickListener(this); // } else { // mVoiceSearchButton.setVisibility(View.GONE); // }//from ww w . j av a 2 s .c o m }
From source file:org.openhab.habdroid.ui.OpenHABMainActivity.java
private void launchVoiceRecognition() { Intent callbackIntent = new Intent(this, OpenHABVoiceService.class); callbackIntent.putExtra(OpenHABVoiceService.OPENHAB_BASE_URL_EXTRA, openHABBaseUrl); PendingIntent openhabPendingIntent = PendingIntent.getService(this, 0, callbackIntent, 0); Intent speechIntent = new Intent(RecognizerIntent.ACTION_RECOGNIZE_SPEECH); // Display an hint to the user about what he should say. speechIntent.putExtra(RecognizerIntent.EXTRA_PROMPT, getString(R.string.info_voice_input)); speechIntent.putExtra(RecognizerIntent.EXTRA_LANGUAGE_MODEL, RecognizerIntent.LANGUAGE_MODEL_FREE_FORM); speechIntent.putExtra(RecognizerIntent.EXTRA_MAX_RESULTS, 1); speechIntent.putExtra(RecognizerIntent.EXTRA_RESULTS_PENDINGINTENT, openhabPendingIntent); try {/*ww w. j a va 2 s .c om*/ startActivity(speechIntent); } catch (ActivityNotFoundException e) { // Speech not installed? Intent browserIntent = new Intent(Intent.ACTION_VIEW, Uri.parse("https://market.android.com/details?id=com.google.android.voicesearch")); startActivity(browserIntent); } }