本文整理汇总了Java中android.support.v17.leanback.widget.SpeechRecognitionCallback类的典型用法代码示例。如果您正苦于以下问题:Java SpeechRecognitionCallback类的具体用法?Java SpeechRecognitionCallback怎么用?Java SpeechRecognitionCallback使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
SpeechRecognitionCallback类属于android.support.v17.leanback.widget包,在下文中一共展示了SpeechRecognitionCallback类的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: setListeners
import android.support.v17.leanback.widget.SpeechRecognitionCallback; //导入依赖的package包/类
private void setListeners() {
setOnItemViewClickedListener(mOnItemViewClickedListener);
setOnItemViewSelectedListener(mOnItemViewSelectedListener);
if (!hasPermission(Manifest.permission.RECORD_AUDIO)) {
setSpeechRecognitionCallback(new SpeechRecognitionCallback() {
@Override
public void recognizeSpeech() {
try {
startActivityForResult(getRecognizerIntent(), REQUEST_SPEECH);
} catch (ActivityNotFoundException error) {
Timber.e(error, "Cannot find activity for speech recognizer");
}
}
});
}
}
示例2: onCreate
import android.support.v17.leanback.widget.SpeechRecognitionCallback; //导入依赖的package包/类
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.search);
mFragment = (SearchFragment) getFragmentManager().findFragmentById(R.id.search_fragment);
if (USE_INTERNAL_SPEECH_RECOGNIZER) {
mSpeechRecognitionCallback = new SpeechRecognitionCallback() {
@Override
public void recognizeSpeech() {
if (DEBUG) {
Log.v(TAG, "recognizeSpeech");
}
startActivityForResult(mFragment.getRecognizerIntent(), REQUEST_SPEECH);
}
};
mFragment.setSpeechRecognitionCallback(mSpeechRecognitionCallback);
}
}
示例3: onCreate
import android.support.v17.leanback.widget.SpeechRecognitionCallback; //导入依赖的package包/类
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.tv_search);
mFragment = (SearchFragment) getFragmentManager()
.findFragmentById(R.id.search_fragment);
SpeechRecognitionCallback speechRecognitionCallback = new SpeechRecognitionCallback() {
@Override
public void recognizeSpeech() {
startActivityForResult(mFragment.getRecognizerIntent(), REQUEST_SPEECH);
}
};
mFragment.setSpeechRecognitionCallback(speechRecognitionCallback);
}
示例4: setListeners
import android.support.v17.leanback.widget.SpeechRecognitionCallback; //导入依赖的package包/类
private void setListeners() {
setOnItemViewClickedListener(mOnItemViewClickedListener);
setOnItemViewSelectedListener(mOnItemViewSelectedListener);
if (!hasPermission(Manifest.permission.RECORD_AUDIO)) {
setSpeechRecognitionCallback(new SpeechRecognitionCallback() {
@Override
public void recognizeSpeech() {
try {
startActivityForResult(getRecognizerIntent(), REQUEST_SPEECH);
} catch (ActivityNotFoundException e) {
Timber.e("Cannot find activity for speech recognizer", e);
}
}
});
}
}
示例5: onCreate
import android.support.v17.leanback.widget.SpeechRecognitionCallback; //导入依赖的package包/类
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
mRowsAdapter = new ArrayObjectAdapter(new ListRowPresenter());
setSearchResultProvider(this);
setOnItemViewClickedListener(new ItemViewClickedListener());
if (!hasPermission(Manifest.permission.RECORD_AUDIO)) {
// SpeechRecognitionCallback is not required and if not provided recognition will be handled
// using internal speech recognizer, in which case you must have RECORD_AUDIO permission
setSpeechRecognitionCallback(new SpeechRecognitionCallback() {
@Override
public void recognizeSpeech() {
if (DEBUG) Log.v(TAG, "recognizeSpeech");
try {
startActivityForResult(getRecognizerIntent(), REQUEST_SPEECH);
} catch (ActivityNotFoundException e) {
Log.e(TAG, "Cannot find activity for speech recognizer", e);
}
}
});
}
}
示例6: onCreate
import android.support.v17.leanback.widget.SpeechRecognitionCallback; //导入依赖的package包/类
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
mRowsAdapter = new ArrayObjectAdapter(new ListRowPresenter());
mVideoCursorAdapter.setMapper(new VideoCursorMapper());
setSearchResultProvider(this);
setOnItemViewClickedListener(new ItemViewClickedListener());
if (DEBUG) {
Log.d(TAG, "User is initiating a search. Do we have RECORD_AUDIO permission? " +
hasPermission(Manifest.permission.RECORD_AUDIO));
}
if (!hasPermission(Manifest.permission.RECORD_AUDIO)) {
if (DEBUG) {
Log.d(TAG, "Does not have RECORD_AUDIO, using SpeechRecognitionCallback");
}
// SpeechRecognitionCallback is not required and if not provided recognition will be
// handled using internal speech recognizer, in which case you must have RECORD_AUDIO
// permission
setSpeechRecognitionCallback(new SpeechRecognitionCallback() {
@Override
public void recognizeSpeech() {
try {
startActivityForResult(getRecognizerIntent(), REQUEST_SPEECH);
} catch (ActivityNotFoundException e) {
Log.e(TAG, "Cannot find activity for speech recognizer", e);
}
}
});
} else if (DEBUG) {
Log.d(TAG, "We DO have RECORD_AUDIO");
}
}
示例7: onCreate
import android.support.v17.leanback.widget.SpeechRecognitionCallback; //导入依赖的package包/类
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
mScraper = new Scraper(getActivity());
mSearchExecutor = new SerialExecutor();
ClassPresenterSelector rowsPresenterSelector = new ClassPresenterSelector();
rowsPresenterSelector.addClassPresenter(ListRow.class, new ListRowPresenter());
rowsPresenterSelector.addClassPresenter(ShadowLessListRow.class, new ShadowLessRowPresenter());
mRowsAdapter = new ArrayObjectAdapter(rowsPresenterSelector);
setBadgeDrawable(getResources().getDrawable(R.mipmap.video2));
setSearchResultProvider(this);
setOnItemViewClickedListener(new OnItemViewClickedListener() {
@Override
public void onItemClicked(Presenter.ViewHolder itemViewHolder, Object item, RowPresenter.ViewHolder rowViewHolder, Row row) {
if (item instanceof BaseTags) {
saveTagsAndFinish((BaseTags) item);
}
}
});
mSpeechRecognitionCallback = new SpeechRecognitionCallback() {
@Override
public void recognizeSpeech() {
// ACTION_RECOGNIZE_SPEECH
try{
startActivityForResult(getRecognizerIntent(), SEARCH_REQUEST_CODE);
}catch (ActivityNotFoundException e){/*non google device*/}
}
};
setSpeechRecognitionCallback(mSpeechRecognitionCallback);
}
示例8: onCreate
import android.support.v17.leanback.widget.SpeechRecognitionCallback; //导入依赖的package包/类
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
mSpinnerFragment = new SpinnerFragment();
mRowsAdapter = new ArrayObjectAdapter(new ListRowPresenter());
mVideoCursorAdapter.setMapper(new VideoCursorMapper());
setSearchResultProvider(this);
setOnItemViewClickedListener(new ItemViewClickedListener());
if (DEBUG) {
Log.d(TAG, "User is initiating a search. Do we have RECORD_AUDIO permission? " +
hasPermission(Manifest.permission.RECORD_AUDIO));
}
if (!hasPermission(Manifest.permission.RECORD_AUDIO)) {
if (DEBUG) {
Log.d(TAG, "Does not have RECORD_AUDIO, using SpeechRecognitionCallback");
}
// SpeechRecognitionCallback is not required and if not provided recognition will be
// handled using internal speech recognizer, in which case you must have RECORD_AUDIO
// permission
setSpeechRecognitionCallback(new SpeechRecognitionCallback() {
@Override
public void recognizeSpeech() {
try {
startActivityForResult(getRecognizerIntent(), REQUEST_SPEECH);
} catch (ActivityNotFoundException e) {
Log.e(TAG, "Cannot find activity for speech recognizer", e);
}
}
});
} else if (DEBUG) {
Log.d(TAG, "We DO have RECORD_AUDIO");
}
}
示例9: onCreate
import android.support.v17.leanback.widget.SpeechRecognitionCallback; //导入依赖的package包/类
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
mRowsAdapter = new ArrayObjectAdapter(new ListRowPresenter());
setSearchResultProvider(this);
setOnItemViewClickedListener(new ItemViewClickedListener());
if (DEBUG) {
Log.d(TAG, "User is initiating a search. Do we have RECORD_AUDIO permission? " +
hasPermission(Manifest.permission.RECORD_AUDIO));
}
if (!hasPermission(Manifest.permission.RECORD_AUDIO)) {
if (DEBUG) {
Log.d(TAG, "Does not have RECORD_AUDIO, using SpeechRecognitionCallback");
}
// SpeechRecognitionCallback is not required and if not provided recognition will be
// handled using internal speech recognizer, in which case you must have RECORD_AUDIO
// permission
setSpeechRecognitionCallback(new SpeechRecognitionCallback() {
@Override
public void recognizeSpeech() {
try {
startActivityForResult(getRecognizerIntent(), REQUEST_SPEECH);
} catch (ActivityNotFoundException e) {
Log.e(TAG, "Cannot find activity for speech recognizer", e);
}
}
});
} else if (DEBUG) {
Log.d(TAG, "We DO have RECORD_AUDIO");
}
}
示例10: initFragment
import android.support.v17.leanback.widget.SpeechRecognitionCallback; //导入依赖的package包/类
private void initFragment() {
fragment = (SearchFragment) getSupportFragmentManager()
.findFragmentById(R.id.ondemand_search_fragment);
fragment.setSpeechRecognitionCallback(new SpeechRecognitionCallback() {
@Override
public void recognizeSpeech() {
Log.d(TAG, "recognizeSpeech");
startActivityForResult(fragment.getRecognizerIntent(), SPEECH_REQUEST_CODE);
}
});
}
示例11: setSpeechRecognitionCallback
import android.support.v17.leanback.widget.SpeechRecognitionCallback; //导入依赖的package包/类
/**
* Set this callback to have the fragment pass speech recognition requests
* to the activity rather than using an internal recognizer.
*/
public void setSpeechRecognitionCallback(SpeechRecognitionCallback callback) {
mSpeechRecognitionCallback = callback;
if (mSearchBar != null) {
mSearchBar.setSpeechRecognitionCallback(mSpeechRecognitionCallback);
}
if (callback != null) {
releaseRecognizer();
}
}
示例12: onCreate
import android.support.v17.leanback.widget.SpeechRecognitionCallback; //导入依赖的package包/类
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
ClassPresenterSelector rowsPresenterSelector = new ClassPresenterSelector();
rowsPresenterSelector.addClassPresenter(ListRow.class, new ListRowPresenter());
rowsPresenterSelector.addClassPresenter(ShadowLessListRow.class, new ShadowLessRowPresenter());
mRowsAdapter = new ArrayObjectAdapter(rowsPresenterSelector);
mSpeechRecognitionCallback = new SpeechRecognitionCallback() {
@Override
public void recognizeSpeech() {
// ACTION_RECOGNIZE_SPEECH
try {
startActivityForResult(getRecognizerIntent(), SEARCH_REQUEST_CODE);
}catch (android.content.ActivityNotFoundException e){
//no google device
}
}
};
setSpeechRecognitionCallback(mSpeechRecognitionCallback);
setSearchResultProvider(this);
setOnItemViewClickedListener(new VideoViewClickedListener(getActivity()));
setBadgeDrawable(getResources().getDrawable(R.mipmap.video2));
mDelayedLoad = new SearchRunnable();
int searchMode = getArguments() != null ? getArguments().getInt(VideoSearchActivity.EXTRA_SEARCH_MODE, VideoSearchActivity.SEARCH_MODE_ALL) : VideoSearchActivity.SEARCH_MODE_ALL;
if (searchMode == VideoSearchActivity.SEARCH_MODE_MOVIE) {
setTitle(getString(R.string.movies));
mSearchLoader = new SearchMovieLoader(getActivity());
} else if (searchMode == VideoSearchActivity.SEARCH_MODE_NON_SCRAPED) {
setTitle(getString(R.string.videos));
mSearchLoader = new SearchNonScrapedVideoLoader(getActivity());
} else {
setTitle(getString(R.string.videos));
mSearchLoader = new SearchVideoLoader(getActivity());
}
}
示例13: onCreate
import android.support.v17.leanback.widget.SpeechRecognitionCallback; //导入依赖的package包/类
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
mRowsAdapter = new ArrayObjectAdapter(new ListRowPresenter());
setSearchResultProvider(this);
setOnItemViewClickedListener(new OnItemViewClickedListener() {
@Override
public void onItemClicked(Presenter.ViewHolder itemViewHolder, Object item, RowPresenter.ViewHolder rowViewHolder, Row row) {
if (item instanceof Track) {
String trackUri = ((Track) item).uri;
SpotifyPlayerController spotifyPlayerController = SpotifyTvApplication.getInstance().getSpotifyPlayerController();
if (spotifyPlayerController.getPlayingState().isCurrentTrack(trackUri)) {
spotifyPlayerController.togglePauseResume();
} else {
// get song and following ones
List<TrackSimple> tracks = new ArrayList<>();
List<String> trackUris = new ArrayList<>();
for (int i = mTrackRowAdapter.indexOf(item); i < mTrackRowAdapter.size() && i < Constants.MAX_SONGS_PLAYED; i++) {
tracks.add((TrackSimple) mTrackRowAdapter.get(i));
trackUris.add(((Track) mTrackRowAdapter.get(i)).uri);
}
spotifyPlayerController.play(trackUri, trackUris, tracks);
}
} else {
SpotifyTvApplication.getInstance().launchDetailScreen(getActivity(), item);
}
}
});
mDelayedLoad = new SearchRunnable();
if (!hasPermission(Manifest.permission.RECORD_AUDIO)) {
// SpeechRecognitionCallback is not required and if not provided recognition will be handled
// using internal speech recognizer, in which case you must have RECORD_AUDIO permission
setSpeechRecognitionCallback(new SpeechRecognitionCallback() {
@Override
public void recognizeSpeech() {
Log.v(TAG, "recognizeSpeech");
try {
startActivityForResult(getRecognizerIntent(), REQUEST_SPEECH);
} catch (ActivityNotFoundException e) {
Log.e(TAG, "Cannot find activity for speech recognizer", e);
}
}
});
}
}