Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can't settext on searchview after using voice recognize speech #247

Closed
wendabizcon opened this issue Jun 6, 2017 · 0 comments
Closed

Can't settext on searchview after using voice recognize speech #247

wendabizcon opened this issue Jun 6, 2017 · 0 comments

Comments

@wendabizcon
Copy link

wendabizcon commented Jun 6, 2017

Error message in the Logcat.
requestLayout() improperly called by android.widget.RelativeLayout{4046e3c I........ ......ID 0,168-1050,1521 #7f0d01a3 app:id/search_suggestions_section} during layout: running second layout pass

mSearchView.setOnMenuItemClickListener(new FloatingSearchView.OnMenuItemClickListener() {
            @Override
            public void onActionMenuItemSelected(MenuItem item) {

                if (item.getItemId() == R.id.action_voice) {

                    Intent intent = new Intent(RecognizerIntent.ACTION_RECOGNIZE_SPEECH);
                    intent.putExtra(RecognizerIntent.EXTRA_LANGUAGE_MODEL, RecognizerIntent.LANGUAGE_MODEL_FREE_FORM);
                    startActivityForResult(intent, SPEECH_REQUEST_CODE);
                }
            }
        });
@Override
    public void onActivityResult(int requestCode, int resultCode, Intent data) {

        super.onActivityResult(requestCode, resultCode, data);

        if (requestCode == SPEECH_REQUEST_CODE && resultCode == RESULT_OK) {

            List<String> results = data.getStringArrayListExtra(RecognizerIntent.EXTRA_RESULTS);
            final String spokenText = results.get(0);

            getActivity().runOnUiThread(new Runnable() {
                public void run() {
                    mSearchView.setSearchText(spokenText);
                }
            });
        }
    }
@wendabizcon wendabizcon changed the title Can't settext on searchview using voice recognize speech Can't settext on searchview after using voice recognize speech Jun 6, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant