List of usage examples for android.speech RecognizerIntent LANGUAGE_MODEL_WEB_SEARCH
String LANGUAGE_MODEL_WEB_SEARCH
To view the source code for android.speech RecognizerIntent LANGUAGE_MODEL_WEB_SEARCH.
Click Source Link
From source file:com.hollowsoft.smarthome.view.MainScreen.java
public void onSpeak(final View view) { ///*from w w w . java 2s . c om*/ // final SpeechRecognizer recognizer = // SpeechRecognizer.createSpeechRecognizer(this); // // final Intent intent = new // Intent(RecognizerIntent.ACTION_RECOGNIZE_SPEECH); // // intent.putExtra(RecognizerIntent.EXTRA_LANGUAGE_MODEL, "pt-BR"); // // recognizer.startListening(intent); // // recognizer.setRecognitionListener(this); final Intent intent = new Intent(RecognizerIntent.ACTION_RECOGNIZE_SPEECH); intent.putExtra(RecognizerIntent.EXTRA_LANGUAGE, "pt-BR"); intent.putExtra(RecognizerIntent.EXTRA_LANGUAGE_MODEL, RecognizerIntent.LANGUAGE_MODEL_WEB_SEARCH); startActivityForResult(intent, 1337); }
From source file:com.uphyca.android.nagiharae.MainActivity.java
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main);/*from w w w . ja va2s.co m*/ FragmentManager manager = getSupportFragmentManager(); mSocketClientFragment = new SocketClientFragment(); manager.beginTransaction().add(mSocketClientFragment, "socket").commit(); findViewById(R.id.button1).setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { mSocketClientFragment.connect(); } }); Fragment f = manager.findFragmentByTag("adk"); if (f == null) { mAdkFragment = new AdkFragment(); manager.beginTransaction().add(mAdkFragment, "adk").commit(); } else { mAdkFragment = (AdkFragment) f; } mAdkFragment.setOnAccessoryStateChangedListener(new AdkFragment.OnAccessoryStateChangedListener() { @Override public void onOpend() { Log.d(TAG, "connected"); mButton.setEnabled(true); } @Override public void onClosed() { Log.d(TAG, "not connected"); mButton.setEnabled(false); } }); mAdkFragment.setOnLedStateChangedListener(new AdkFragment.OnLedStateChangedListener() { @Override public void ledStateChanged(boolean isOn) { if (isOn) { // ??? Toast.makeText(MainActivity.this, "??", Toast.LENGTH_LONG).show(); } else { Toast.makeText(MainActivity.this, "?", Toast.LENGTH_LONG).show(); } } }); mButton = (Button) findViewById(R.id.button); mButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { try { Intent intent = new Intent(RecognizerIntent.ACTION_RECOGNIZE_SPEECH); // ACTION_WEB_SEARCH intent.putExtra(RecognizerIntent.EXTRA_LANGUAGE_MODEL, RecognizerIntent.LANGUAGE_MODEL_WEB_SEARCH); intent.putExtra(RecognizerIntent.EXTRA_PROMPT, "??"); startActivityForResult(intent, REQUEST_CODE); } catch (ActivityNotFoundException e) { // ????????????? Toast.makeText(MainActivity.this, "ActivityNotFoundException", Toast.LENGTH_LONG).show(); } } }); }
From source file:com.ksutopia.bbtalks.plugins.P201SpeechToText.java
/** * Fire an intent to start the speech recognition activity. *//from w w w . j a va 2 s. c o m * @param args Argument array with the following string args: [req code][number of matches][prompt string] */ private void startSpeechRecognitionActivity(JSONArray args) { int maxMatches = 0; String prompt = ""; String language = Locale.getDefault().toString(); try { if (args.length() > 0) { // Maximum number of matches, 0 means the recognizer decides String temp = args.getString(0); maxMatches = Integer.parseInt(temp); } if (args.length() > 1) { // Optional text prompt prompt = args.getString(1); } if (args.length() > 2) { // Optional language specified language = args.getString(2); } } catch (Exception e) { Log.e(LOG_TAG, String.format("startSpeechRecognitionActivity exception: %s", e.toString())); } // Create the intent and set parameters speech = SpeechRecognizer.createSpeechRecognizer(context); recognizerIntent = new Intent(RecognizerIntent.ACTION_RECOGNIZE_SPEECH); recognizerIntent.putExtra(RecognizerIntent.EXTRA_LANGUAGE_MODEL, RecognizerIntent.LANGUAGE_MODEL_FREE_FORM); recognizerIntent.putExtra(RecognizerIntent.EXTRA_CALLING_PACKAGE, context.getPackageName()); recognizerIntent.putExtra(RecognizerIntent.EXTRA_LANGUAGE_PREFERENCE, "en"); recognizerIntent.putExtra(RecognizerIntent.EXTRA_LANGUAGE_MODEL, RecognizerIntent.LANGUAGE_MODEL_WEB_SEARCH); if (maxMatches > 0) recognizerIntent.putExtra(RecognizerIntent.EXTRA_MAX_RESULTS, maxMatches); if (!prompt.equals("")) recognizerIntent.putExtra(RecognizerIntent.EXTRA_PROMPT, prompt); speech.setRecognitionListener(listener); speech.startListening(recognizerIntent); }
From source file:conversandroid.RichASR.java
/** * Starts speech recognition after checking the ASR parameters * * @param language Language used for speech recognition (e.g. Locale.ENGLISH) * @param languageModel Type of language model used (free form or web search) * @param maxResults Maximum number of recognition results *///from w ww. ja v a 2 s. c om public void listen(final Locale language, final String languageModel, final int maxResults) { Button b = (Button) findViewById(R.id.speech_btn); b.setEnabled(false); if ((languageModel.equals(RecognizerIntent.LANGUAGE_MODEL_FREE_FORM) || languageModel.equals(RecognizerIntent.LANGUAGE_MODEL_WEB_SEARCH)) && (maxResults >= 0)) { // Check we have permission to record audio checkASRPermission(); Intent intent = new Intent(RecognizerIntent.ACTION_RECOGNIZE_SPEECH); // Specify the calling package to identify the application intent.putExtra(RecognizerIntent.EXTRA_CALLING_PACKAGE, getPackageName()); //Caution: be careful not to use: getClass().getPackage().getName()); // Specify language model intent.putExtra(RecognizerIntent.EXTRA_LANGUAGE_MODEL, languageModel); // Specify how many results to receive. Results listed in order of confidence intent.putExtra(RecognizerIntent.EXTRA_MAX_RESULTS, maxResults); // Specify recognition language intent.putExtra(RecognizerIntent.EXTRA_LANGUAGE, language); Log.i(LOGTAG, "Going to start listening..."); this.startListeningTime = System.currentTimeMillis(); myASR.startListening(intent); } else { Log.e(LOGTAG, "Invalid params to listen method"); ((TextView) findViewById(R.id.feedbackTxt)).setText("Error: invalid parameters"); } }
From source file:atlc.granadaaccessibilityranking.VoiceActivity.java
/** * Starts speech recognition after checking the ASR parameters * * @param language Language used for speech recognition (e.g. Locale.ENGLISH) * @param languageModel Type of language model used (free form or web search) * @param maxResults Maximum number of recognition results * @exception An exception is raised if the language specified is not available or the other parameters are not valid */// www .jav a 2 s. c om public void listen(final Locale language, final String languageModel, final int maxResults) throws Exception { checkASRPermission(); if ((languageModel.equals(RecognizerIntent.LANGUAGE_MODEL_FREE_FORM) || languageModel.equals(RecognizerIntent.LANGUAGE_MODEL_WEB_SEARCH)) && (maxResults >= 0)) { Intent intent = new Intent(RecognizerIntent.ACTION_RECOGNIZE_SPEECH); // Specify the calling package to identify the application intent.putExtra(RecognizerIntent.EXTRA_CALLING_PACKAGE, ctx.getPackageName()); //Caution: be careful not to use: getClass().getPackage().getName()); // Specify language model intent.putExtra(RecognizerIntent.EXTRA_LANGUAGE_MODEL, languageModel); // Specify how many results to receive. Results listed in order of confidence intent.putExtra(RecognizerIntent.EXTRA_MAX_RESULTS, maxResults); // Specify recognition language intent.putExtra(RecognizerIntent.EXTRA_LANGUAGE, language); myASR.startListening(intent); } else { Log.e(LOGTAG, "Invalid params to listen method"); throw new Exception("Invalid params to listen method"); //If the input parameters are not valid, it throws an exception } }
From source file:com.justplay1.shoppist.features.search.SearchFragment.java
private void startTextToSpeech(String prompt, int requestCode) { Intent intent = new Intent(RecognizerIntent.ACTION_RECOGNIZE_SPEECH); intent.putExtra(RecognizerIntent.EXTRA_LANGUAGE_MODEL, RecognizerIntent.LANGUAGE_MODEL_WEB_SEARCH); intent.putExtra(RecognizerIntent.EXTRA_LANGUAGE, Locale.getDefault()); intent.putExtra(RecognizerIntent.EXTRA_PROMPT, prompt); try {// ww w . ja v a2 s. c om startActivityForResult(intent, requestCode); } catch (ActivityNotFoundException a) { Toast.makeText(getContext(), getString(R.string.recognition_not_present), Toast.LENGTH_SHORT).show(); } }
From source file:com.delexus.imitationzhihu.MySearchView.java
public MySearchView(Context context, AttributeSet attrs, int defStyleAttr) { super(context, attrs, defStyleAttr); final TintTypedArray a = TintTypedArray.obtainStyledAttributes(context, attrs, R.styleable.MySearchView, defStyleAttr, 0);//from w ww .j a v a 2s . c o m final LayoutInflater inflater = LayoutInflater.from(context); inflater.inflate(R.layout.search_view, this); mSearchSrcTextView = (SearchAutoComplete) findViewById(R.id.my_search_src_text); mSearchSrcTextView.setSearchView(this); mNavigationButton = (ImageView) findViewById(R.id.my_search_button); mGoButton = (ImageView) findViewById(R.id.my_search_go_btn); mCloseButton = (ImageView) findViewById(R.id.my_search_close_btn); mVoiceButton = (ImageView) findViewById(R.id.my_search_voice_btn); // Set up icons and backgrounds. mNavigationButton.setImageDrawable(a.getDrawable(R.styleable.MySearchView_navigateIcon)); mGoButton.setImageDrawable(a.getDrawable(R.styleable.MySearchView_goIcon)); mCloseButton.setImageDrawable(a.getDrawable(R.styleable.MySearchView_closeIcon)); mVoiceButton.setImageDrawable(a.getDrawable(R.styleable.MySearchView_voiceIcon)); mSearchHintIcon = a.getDrawable(R.styleable.MySearchView_searchHintIcon); mNavigationButton.setOnClickListener(mOnClickListener); mCloseButton.setOnClickListener(mOnClickListener); mGoButton.setOnClickListener(mOnClickListener); mVoiceButton.setOnClickListener(mOnClickListener); mSearchSrcTextView.setOnClickListener(mOnClickListener); mSearchSrcTextView.addTextChangedListener(mTextWatcher); mSearchSrcTextView.setOnEditorActionListener(mOnEditorActionListener); mSearchSrcTextView.setOnKeyListener(mTextKeyListener); // Inform any listener of focus changes mSearchSrcTextView.setOnFocusChangeListener(new OnFocusChangeListener() { @Override public void onFocusChange(View v, boolean hasFocus) { if (mOnQueryTextFocusChangeListener != null) { mOnQueryTextFocusChangeListener.onFocusChange(MySearchView.this, hasFocus); } } }); setIconifiedByDefault(a.getBoolean(R.styleable.MySearchView_iconifiedByDefault, true)); final int maxWidth = a.getDimensionPixelSize(R.styleable.MySearchView_android_maxWidth, -1); if (maxWidth != -1) { setMaxWidth(maxWidth); } mDefaultQueryHint = a.getText(R.styleable.MySearchView_defaultQueryHint); mQueryHint = a.getText(R.styleable.MySearchView_queryHint); final int imeOptions = a.getInt(R.styleable.MySearchView_android_imeOptions, -1); if (imeOptions != -1) { setImeOptions(imeOptions); } final int inputType = a.getInt(R.styleable.MySearchView_android_inputType, -1); if (inputType != -1) { setInputType(inputType); } boolean focusable = true; focusable = a.getBoolean(R.styleable.MySearchView_android_inputType, focusable); setFocusable(focusable); a.recycle(); // Save voice intent for later queries/launching mVoiceWebSearchIntent = new Intent(RecognizerIntent.ACTION_WEB_SEARCH); mVoiceWebSearchIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); mVoiceWebSearchIntent.putExtra(RecognizerIntent.EXTRA_LANGUAGE_MODEL, RecognizerIntent.LANGUAGE_MODEL_WEB_SEARCH); mVoiceAppSearchIntent = new Intent(RecognizerIntent.ACTION_RECOGNIZE_SPEECH); mVoiceAppSearchIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); updateViewsVisibility(mIconifiedByDefault); updateQueryHint(); }
From source file:io.github.vomitcuddle.SearchViewAllowEmpty.SearchView.java
public SearchView(Context context, AttributeSet attrs) { super(context, attrs); LayoutInflater inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE); inflater.inflate(R.layout.cba_search_view, this, true); mSearchButton = findViewById(R.id.search_button); mQueryTextView = (SearchAutoComplete) findViewById(R.id.search_src_text); mQueryTextView.setSearchView(this); mSearchEditFrame = findViewById(R.id.search_edit_frame); mSearchPlate = findViewById(R.id.search_plate); mSubmitArea = findViewById(R.id.submit_area); mSubmitButton = findViewById(R.id.search_go_btn); mCloseButton = (ImageView) findViewById(R.id.search_close_btn); mVoiceButton = findViewById(R.id.search_voice_btn); mSearchHintIcon = (ImageView) findViewById(R.id.search_mag_icon); mSearchButton.setOnClickListener(mOnClickListener); mCloseButton.setOnClickListener(mOnClickListener); mSubmitButton.setOnClickListener(mOnClickListener); mVoiceButton.setOnClickListener(mOnClickListener); mQueryTextView.setOnClickListener(mOnClickListener); mQueryTextView.addTextChangedListener(mTextWatcher); mQueryTextView.setOnEditorActionListener(mOnEditorActionListener); mQueryTextView.setOnItemClickListener(mOnItemClickListener); mQueryTextView.setOnItemSelectedListener(mOnItemSelectedListener); mQueryTextView.setOnKeyListener(mTextKeyListener); // Inform any listener of focus changes mQueryTextView.setOnFocusChangeListener(new OnFocusChangeListener() { public void onFocusChange(View v, boolean hasFocus) { if (mOnQueryTextFocusChangeListener != null) { mOnQueryTextFocusChangeListener.onFocusChange(SearchView.this, hasFocus); }/*from www .ja v a2 s .co m*/ } }); TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.SearchView, 0, 0); setIconifiedByDefault(a.getBoolean(R.styleable.SearchView_iconifiedByDefault, true)); int maxWidth = a.getDimensionPixelSize(R.styleable.SearchView_android_maxWidth, -1); if (maxWidth != -1) { setMaxWidth(maxWidth); } CharSequence queryHint = a.getText(R.styleable.SearchView_queryHint); if (!TextUtils.isEmpty(queryHint)) { setQueryHint(queryHint); } int imeOptions = a.getInt(R.styleable.SearchView_android_imeOptions, -1); if (imeOptions != -1) { setImeOptions(imeOptions); } int inputType = a.getInt(R.styleable.SearchView_android_inputType, -1); if (inputType != -1) { setInputType(inputType); } a.recycle(); boolean focusable = true; a = context.obtainStyledAttributes(attrs, R.styleable.View, 0, 0); focusable = a.getBoolean(R.styleable.View_android_focusable, focusable); a.recycle(); setFocusable(focusable); // Save voice intent for later queries/launching mVoiceWebSearchIntent = new Intent(RecognizerIntent.ACTION_WEB_SEARCH); mVoiceWebSearchIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); mVoiceWebSearchIntent.putExtra(RecognizerIntent.EXTRA_LANGUAGE_MODEL, RecognizerIntent.LANGUAGE_MODEL_WEB_SEARCH); mVoiceAppSearchIntent = new Intent(RecognizerIntent.ACTION_RECOGNIZE_SPEECH); mVoiceAppSearchIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); mDropDownAnchor = findViewById(mQueryTextView.getDropDownAnchor()); if (mDropDownAnchor != null) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) { addOnLayoutChangeListenerToDropDownAnchorSDK11(); } else { addOnLayoutChangeListenerToDropDownAnchorBase(); } } updateViewsVisibility(mIconifiedByDefault); updateQueryHint(); }
From source file:cm.aptoide.com.actionbarsherlock.widget.SearchView.java
public SearchView(Context context, AttributeSet attrs) { super(context, attrs); if (Build.VERSION.SDK_INT < Build.VERSION_CODES.FROYO) { throw new IllegalStateException("SearchView is API 8+ only."); }// ww w. j a va2 s .c om LayoutInflater inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE); inflater.inflate(R.layout.abs__search_view, this, true); mSearchButton = findViewById(R.id.abs__search_button); mQueryTextView = (SearchAutoComplete) findViewById(R.id.abs__search_src_text); mQueryTextView.setSearchView(this); mSearchEditFrame = findViewById(R.id.abs__search_edit_frame); mSearchPlate = findViewById(R.id.abs__search_plate); mSubmitArea = findViewById(R.id.abs__submit_area); mSubmitButton = findViewById(R.id.abs__search_go_btn); mCloseButton = (ImageView) findViewById(R.id.abs__search_close_btn); mVoiceButton = findViewById(R.id.abs__search_voice_btn); mSearchHintIcon = (ImageView) findViewById(R.id.abs__search_mag_icon); mSearchButton.setOnClickListener(mOnClickListener); mCloseButton.setOnClickListener(mOnClickListener); mSubmitButton.setOnClickListener(mOnClickListener); mVoiceButton.setOnClickListener(mOnClickListener); mQueryTextView.setOnClickListener(mOnClickListener); mQueryTextView.addTextChangedListener(mTextWatcher); mQueryTextView.setOnEditorActionListener(mOnEditorActionListener); mQueryTextView.setOnItemClickListener(mOnItemClickListener); mQueryTextView.setOnItemSelectedListener(mOnItemSelectedListener); mQueryTextView.setOnKeyListener(mTextKeyListener); // Inform any listener of focus changes mQueryTextView.setOnFocusChangeListener(new OnFocusChangeListener() { public void onFocusChange(View v, boolean hasFocus) { if (mOnQueryTextFocusChangeListener != null) { mOnQueryTextFocusChangeListener.onFocusChange(SearchView.this, hasFocus); } } }); TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.SherlockSearchView, 0, 0); setIconifiedByDefault(a.getBoolean(R.styleable.SherlockSearchView_iconifiedByDefault, true)); int maxWidth = a.getDimensionPixelSize(R.styleable.SherlockSearchView_android_maxWidth, -1); if (maxWidth != -1) { setMaxWidth(maxWidth); } CharSequence queryHint = a.getText(R.styleable.SherlockSearchView_queryHint); if (!TextUtils.isEmpty(queryHint)) { setQueryHint(queryHint); } int imeOptions = a.getInt(R.styleable.SherlockSearchView_android_imeOptions, -1); if (imeOptions != -1) { setImeOptions(imeOptions); } int inputType = a.getInt(R.styleable.SherlockSearchView_android_inputType, -1); if (inputType != -1) { setInputType(inputType); } a.recycle(); boolean focusable = true; a = context.obtainStyledAttributes(attrs, R.styleable.SherlockView, 0, 0); focusable = a.getBoolean(R.styleable.SherlockView_android_focusable, focusable); a.recycle(); setFocusable(focusable); // Save voice intent for later queries/launching mVoiceWebSearchIntent = new Intent(RecognizerIntent.ACTION_WEB_SEARCH); mVoiceWebSearchIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); mVoiceWebSearchIntent.putExtra(RecognizerIntent.EXTRA_LANGUAGE_MODEL, RecognizerIntent.LANGUAGE_MODEL_WEB_SEARCH); mVoiceAppSearchIntent = new Intent(RecognizerIntent.ACTION_RECOGNIZE_SPEECH); mVoiceAppSearchIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); mDropDownAnchor = findViewById(mQueryTextView.getDropDownAnchor()); if (mDropDownAnchor != null) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) { mDropDownAnchor.addOnLayoutChangeListener(new OnLayoutChangeListener() { @Override public void onLayoutChange(View v, int left, int top, int right, int bottom, int oldLeft, int oldTop, int oldRight, int oldBottom) { adjustDropDownSizeAndPosition(); } }); } else { mDropDownAnchor.getViewTreeObserver() .addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() { @Override public void onGlobalLayout() { adjustDropDownSizeAndPosition(); } }); } } updateViewsVisibility(mIconifiedByDefault); updateQueryHint(); }
From source file:lewa.support.v7.widget.SearchView.java
public SearchView(Context context, AttributeSet attrs) { super(context, attrs); LayoutInflater inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE); inflater.inflate(R.layout.abc_search_view, this, true); mSearchButton = findViewById(R.id.search_button); mQueryTextView = (SearchAutoComplete) findViewById(R.id.search_src_text); mQueryTextView.setSearchView(this); mSearchEditFrame = findViewById(R.id.search_edit_frame); mSearchPlate = findViewById(R.id.search_plate); mSubmitArea = findViewById(R.id.submit_area); mSubmitButton = findViewById(R.id.search_go_btn); mCloseButton = (ImageView) findViewById(R.id.search_close_btn); mVoiceButton = findViewById(R.id.search_voice_btn); mSearchHintIcon = (ImageView) findViewById(R.id.search_mag_icon); mSearchButton.setOnClickListener(mOnClickListener); mCloseButton.setOnClickListener(mOnClickListener); mSubmitButton.setOnClickListener(mOnClickListener); mVoiceButton.setOnClickListener(mOnClickListener); mQueryTextView.setOnClickListener(mOnClickListener); mQueryTextView.addTextChangedListener(mTextWatcher); mQueryTextView.setOnEditorActionListener(mOnEditorActionListener); mQueryTextView.setOnItemClickListener(mOnItemClickListener); mQueryTextView.setOnItemSelectedListener(mOnItemSelectedListener); mQueryTextView.setOnKeyListener(mTextKeyListener); // Inform any listener of focus changes mQueryTextView.setOnFocusChangeListener(new OnFocusChangeListener() { public void onFocusChange(View v, boolean hasFocus) { if (mOnQueryTextFocusChangeListener != null) { mOnQueryTextFocusChangeListener.onFocusChange(SearchView.this, hasFocus); }//from w ww. ja va2 s. c om } }); TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.SearchView, 0, 0); mSearchIconResId = a.getResourceId(R.styleable.SearchView_searchIcon, 0); setIconifiedByDefault(a.getBoolean(R.styleable.SearchView_iconifiedByDefault, true)); int maxWidth = a.getDimensionPixelSize(R.styleable.SearchView_android_maxWidth, -1); if (maxWidth != -1) { setMaxWidth(maxWidth); } CharSequence queryHint = a.getText(R.styleable.SearchView_queryHint); if (!TextUtils.isEmpty(queryHint)) { setQueryHint(queryHint); } int imeOptions = a.getInt(R.styleable.SearchView_android_imeOptions, -1); if (imeOptions != -1) { setImeOptions(imeOptions); } int inputType = a.getInt(R.styleable.SearchView_android_inputType, -1); if (inputType != -1) { setInputType(inputType); } a.recycle(); boolean focusable = true; a = context.obtainStyledAttributes(attrs, R.styleable.View, 0, 0); focusable = a.getBoolean(R.styleable.View_android_focusable, focusable); a.recycle(); setFocusable(focusable); // Save voice intent for later queries/launching mVoiceWebSearchIntent = new Intent(RecognizerIntent.ACTION_WEB_SEARCH); mVoiceWebSearchIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); mVoiceWebSearchIntent.putExtra(RecognizerIntent.EXTRA_LANGUAGE_MODEL, RecognizerIntent.LANGUAGE_MODEL_WEB_SEARCH); mVoiceAppSearchIntent = new Intent(RecognizerIntent.ACTION_RECOGNIZE_SPEECH); mVoiceAppSearchIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); mDropDownAnchor = findViewById(mQueryTextView.getDropDownAnchor()); if (mDropDownAnchor != null) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) { addOnLayoutChangeListenerToDropDownAnchorSDK11(); } else { addOnLayoutChangeListenerToDropDownAnchorBase(); } } updateViewsVisibility(mIconifiedByDefault); updateQueryHint(); }