Java Code Examples for org.chromium.chrome.browser.util.FeatureUtilities#isRecognitionIntentPresent()
The following examples show how to use
org.chromium.chrome.browser.util.FeatureUtilities#isRecognitionIntentPresent() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: LocationBarLayout.java From delion with Apache License 2.0 | 5 votes |
@Override public boolean isVoiceSearchEnabled() { if (mToolbarDataProvider == null) return false; if (mToolbarDataProvider.isIncognito()) return false; if (mWindowAndroid == null) return false; if (!mWindowAndroid.hasPermission(Manifest.permission.RECORD_AUDIO) && !mWindowAndroid.canRequestPermission(Manifest.permission.RECORD_AUDIO)) { return false; } return FeatureUtilities.isRecognitionIntentPresent(getContext(), true); }
Example 2
Source File: LocationBarLayout.java From AndroidChromium with Apache License 2.0 | 5 votes |
@Override public boolean isVoiceSearchEnabled() { if (mToolbarDataProvider == null) return false; if (mToolbarDataProvider.isIncognito()) return false; if (mWindowAndroid == null) return false; if (!mWindowAndroid.hasPermission(Manifest.permission.RECORD_AUDIO) && !mWindowAndroid.canRequestPermission(Manifest.permission.RECORD_AUDIO)) { return false; } return FeatureUtilities.isRecognitionIntentPresent(getContext(), true); }
Example 3
Source File: LocationBarLayout.java From 365browser with Apache License 2.0 | 5 votes |
@Override public boolean isVoiceSearchEnabled() { if (mToolbarDataProvider == null) return false; if (mToolbarDataProvider.isIncognito()) return false; if (mWindowAndroid == null) return false; if (!mWindowAndroid.hasPermission(Manifest.permission.RECORD_AUDIO) && !mWindowAndroid.canRequestPermission(Manifest.permission.RECORD_AUDIO)) { return false; } return FeatureUtilities.isRecognitionIntentPresent(getContext(), true); }
Example 4
Source File: LocationBarLayout.java From delion with Apache License 2.0 | 4 votes |
/** * Triggers a voice recognition intent to allow the user to specify a search query. */ @Override public void startVoiceRecognition() { Activity activity = mWindowAndroid.getActivity().get(); if (activity == null) return; if (!mWindowAndroid.hasPermission(Manifest.permission.RECORD_AUDIO)) { if (mWindowAndroid.canRequestPermission(Manifest.permission.RECORD_AUDIO)) { WindowAndroid.PermissionCallback callback = new WindowAndroid.PermissionCallback() { @Override public void onRequestPermissionsResult( String[] permissions, int[] grantResults) { if (grantResults.length != 1) return; if (grantResults[0] == PackageManager.PERMISSION_GRANTED) { startVoiceRecognition(); } else { updateMicButtonState(); } } }; mWindowAndroid.requestPermissions( new String[] {Manifest.permission.RECORD_AUDIO}, callback); } else { updateMicButtonState(); } return; } Intent intent = new Intent(RecognizerIntent.ACTION_RECOGNIZE_SPEECH); intent.putExtra(RecognizerIntent.EXTRA_LANGUAGE_MODEL, RecognizerIntent.LANGUAGE_MODEL_WEB_SEARCH); intent.putExtra(RecognizerIntent.EXTRA_CALLING_PACKAGE, activity.getComponentName().flattenToString()); intent.putExtra(RecognizerIntent.EXTRA_WEB_SEARCH_ONLY, true); if (mWindowAndroid.showCancelableIntent(intent, this, R.string.voice_search_error) < 0) { // Requery whether or not the recognition intent can be handled. FeatureUtilities.isRecognitionIntentPresent(activity, false); updateMicButtonState(); } }
Example 5
Source File: LocationBarLayout.java From AndroidChromium with Apache License 2.0 | 4 votes |
/** * Triggers a voice recognition intent to allow the user to specify a search query. */ @Override public void startVoiceRecognition() { Activity activity = mWindowAndroid.getActivity().get(); if (activity == null) return; if (!mWindowAndroid.hasPermission(Manifest.permission.RECORD_AUDIO)) { if (mWindowAndroid.canRequestPermission(Manifest.permission.RECORD_AUDIO)) { WindowAndroid.PermissionCallback callback = new WindowAndroid.PermissionCallback() { @Override public void onRequestPermissionsResult( String[] permissions, int[] grantResults) { if (grantResults.length != 1) return; if (grantResults[0] == PackageManager.PERMISSION_GRANTED) { startVoiceRecognition(); } else { updateMicButtonState(); } } }; mWindowAndroid.requestPermissions( new String[] {Manifest.permission.RECORD_AUDIO}, callback); } else { updateMicButtonState(); } return; } Intent intent = new Intent(RecognizerIntent.ACTION_RECOGNIZE_SPEECH); intent.putExtra(RecognizerIntent.EXTRA_LANGUAGE_MODEL, RecognizerIntent.LANGUAGE_MODEL_WEB_SEARCH); intent.putExtra(RecognizerIntent.EXTRA_CALLING_PACKAGE, activity.getComponentName().flattenToString()); intent.putExtra(RecognizerIntent.EXTRA_WEB_SEARCH_ONLY, true); if (mWindowAndroid.showCancelableIntent(intent, this, R.string.voice_search_error) < 0) { // Requery whether or not the recognition intent can be handled. FeatureUtilities.isRecognitionIntentPresent(activity, false); updateMicButtonState(); } }
Example 6
Source File: LocationBarLayout.java From 365browser with Apache License 2.0 | 4 votes |
/** * Triggers a voice recognition intent to allow the user to specify a search query. */ @Override public void startVoiceRecognition() { Activity activity = mWindowAndroid.getActivity().get(); if (activity == null) return; if (!mWindowAndroid.hasPermission(Manifest.permission.RECORD_AUDIO)) { if (mWindowAndroid.canRequestPermission(Manifest.permission.RECORD_AUDIO)) { WindowAndroid.PermissionCallback callback = new WindowAndroid.PermissionCallback() { @Override public void onRequestPermissionsResult( String[] permissions, int[] grantResults) { if (grantResults.length != 1) return; if (grantResults[0] == PackageManager.PERMISSION_GRANTED) { startVoiceRecognition(); } else { updateMicButtonState(); } } }; mWindowAndroid.requestPermissions( new String[] {Manifest.permission.RECORD_AUDIO}, callback); } else { updateMicButtonState(); } return; } Intent intent = new Intent(RecognizerIntent.ACTION_RECOGNIZE_SPEECH); intent.putExtra(RecognizerIntent.EXTRA_LANGUAGE_MODEL, RecognizerIntent.LANGUAGE_MODEL_WEB_SEARCH); intent.putExtra(RecognizerIntent.EXTRA_CALLING_PACKAGE, activity.getComponentName().flattenToString()); intent.putExtra(RecognizerIntent.EXTRA_WEB_SEARCH_ONLY, true); if (mWindowAndroid.showCancelableIntent(intent, this, R.string.voice_search_error) < 0) { // Requery whether or not the recognition intent can be handled. FeatureUtilities.isRecognitionIntentPresent(activity, false); updateMicButtonState(); } }