当前位置: 首页>>代码示例>>Java>>正文


Java SpeechRecognitionCallback类代码示例

本文整理汇总了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");
                }
            }
        });
    }
}
 
开发者ID:hitherejoe,项目名称:AndroidTvBoilerplate,代码行数:17,代码来源:SearchContentFragment.java

示例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);
    }
}
 
开发者ID:googlesamples,项目名称:leanback-showcase,代码行数:19,代码来源:SearchActivity.java

示例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);
}
 
开发者ID:hanhailong,项目名称:VCL-Android,代码行数:18,代码来源:SearchActivity.java

示例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);
                }
            }
        });
    }
}
 
开发者ID:hitherejoe,项目名称:Vineyard,代码行数:17,代码来源:SearchFragment.java

示例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);
                }
            }
        });
    }
}
 
开发者ID:dextorer,项目名称:BuildingForAndroidTV,代码行数:24,代码来源:SearchFragment.java

示例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");
    }
}
 
开发者ID:nejtv,项目名称:androidtv-sample,代码行数:35,代码来源:SearchFragment.java

示例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);
}
 
开发者ID:archos-sa,项目名称:aos-Video,代码行数:36,代码来源:ManualScrappingSearchFragment.java

示例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");
    }
}
 
开发者ID:ad-on-is,项目名称:chilly,代码行数:34,代码来源:SearchFragment.java

示例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");
    }
}
 
开发者ID:ITVlab,项目名称:android-tv-news,代码行数:34,代码来源:SearchFragment.java

示例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);
    }
  });
}
 
开发者ID:mkjensen,项目名称:danish-media-license,代码行数:12,代码来源:SearchActivity.java

示例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();
    }
}
 
开发者ID:kingargyle,项目名称:adt-leanback-support,代码行数:14,代码来源:SearchSupportFragment.java

示例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());
    }
}
 
开发者ID:archos-sa,项目名称:aos-Video,代码行数:42,代码来源:VideoSearchFragment.java

示例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);
                }
            }
        });
    }
}
 
开发者ID:sregg,项目名称:spotify-tv,代码行数:48,代码来源:SearchFragment.java


注:本文中的android.support.v17.leanback.widget.SpeechRecognitionCallback类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。