Example usage for android.speech RecognizerIntent EXTRA_RESULTS

List of usage examples for android.speech RecognizerIntent EXTRA_RESULTS

Introduction

In this page you can find the example usage for android.speech RecognizerIntent EXTRA_RESULTS.

Prototype

String EXTRA_RESULTS

To view the source code for android.speech RecognizerIntent EXTRA_RESULTS.

Click Source Link

Document

An ArrayList<String> of the recognition results when performing #ACTION_RECOGNIZE_SPEECH .

Usage

From source file:org.protocoderrunner.base.BaseActivity.java

/**
 * Handle the results from the recognition activity.
 *///from ww w  .j  av  a  2s.  c o m
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    if (requestCode == Audio.VOICE_RECOGNITION_REQUEST_CODE && resultCode == RESULT_OK) {
        // Fill the list view with the strings the recognizer thought it
        // could have heard
        ArrayList<String> matches = data.getStringArrayListExtra(RecognizerIntent.EXTRA_RESULTS);

        for (String _string : matches) {
            MLog.d(TAG, "" + _string);
        }

    }

    super.onActivityResult(requestCode, resultCode, data);
}

From source file:com.pixplicity.castdemo.MainActivity.java

@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    if (requestCode == REQUEST_SPEECH_RECOGNITION && resultCode == RESULT_OK) {
        ArrayList<String> matches = data.getStringArrayListExtra(RecognizerIntent.EXTRA_RESULTS);
        if (matches.size() > 0) {
            String message = matches.get(0);
            if (!CastProxy.getChannel().sendMessage(message)) {
                mEtMessage.setText(message);
            }//from   ww w .j av  a2  s.  c  o  m
        }
    }
    super.onActivityResult(requestCode, resultCode, data);
}

From source file:org.catrobat.catroid.ui.ScratchConverterActivity.java

@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
    if (requestCode == Constants.INTENT_REQUEST_CODE_SPEECH && resultCode == RESULT_OK) {
        List<String> results = data.getStringArrayListExtra(RecognizerIntent.EXTRA_RESULTS);
        String spokenText = results.get(0);
        searchProjectsListFragment.searchAndUpdateText(spokenText);
    } else if (requestCode == Constants.INTENT_REQUEST_CODE_CONVERT && resultCode == RESULT_OK) {
        if (!data.hasExtra(Constants.INTENT_SCRATCH_PROGRAM_DATA)) {
            super.onActivityResult(requestCode, resultCode, data);
            return;
        }/*from  w  w w.java 2 s .  co m*/
        final ScratchProgramData projectData = data.getParcelableExtra(Constants.INTENT_SCRATCH_PROGRAM_DATA);
        final List<ScratchProgramData> projectList = new ArrayList<>();
        projectList.add(projectData);
        convertProjects(projectList);
    }
    super.onActivityResult(requestCode, resultCode, data);
}

From source file:com.google.sample.cast.refplayer.chatting.MainActivity.java

@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    Log.d(TAG, "~~~~~~~~~~ onActivityResult");
    if (requestCode == REQUEST_CODE && resultCode == RESULT_OK) {
        ArrayList<String> matches = data.getStringArrayListExtra(RecognizerIntent.EXTRA_RESULTS);
        if (matches.size() > 0) {
            Log.d(TAG, matches.get(0));/*from   www  .  j av  a  2  s.  com*/
            sendMessage(matches.get(0));
        }
    }
    super.onActivityResult(requestCode, resultCode, data);
}

From source file:com.ct.speech.HintReceiver.java

/**
 * Handle the results from the recognition activity.
 *//*from w  w w  .j ava  2s. co  m*/
@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
    if (resultCode == Activity.RESULT_OK) {
        // Fill the list view with the strings the recognizer thought it
        // could have heard
        ArrayList<String> matches = data.getStringArrayListExtra(RecognizerIntent.EXTRA_RESULTS);
        speechResults(requestCode, matches);

    } else if (resultCode == Activity.RESULT_CANCELED) {
        // cancelled by user
        speechFailure("Cancelled");
    } else {
        speechFailure("Unknown error");
    }

    super.onActivityResult(requestCode, resultCode, data);
}

From source file:org.bishoph.oxdemo.OXDemo.java

@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    Log.v("OXDemo", "onActivityResult " + resultCode + " // " + RESULT_OK);
    if (requestCode == VOICE_RECOGNITION_REQUEST_CODE && resultCode == RESULT_OK) {
        ArrayList<String> matches = data.getStringArrayListExtra(RecognizerIntent.EXTRA_RESULTS);
        Log.v("OXDemo", "All text reconition: " + matches);
        if (matches != null && !matches.isEmpty()) {
            String bestResult = matches.get(0).toString();
            if (bestResult != null && bestResult.length() > 0) {
                Log.v("OXDemo", "Best result from text reconition: " + bestResult);
                if (folder_id > -1) {
                    createTask(folder_id, bestResult);
                }/*ww  w.  j  av a 2s.c o m*/
            }
        }
    }
    super.onActivityResult(requestCode, resultCode, data);
}

From source file:org.botlibre.sdk.activity.MicConfiguration.java

@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    super.onActivityResult(requestCode, resultCode, data);

    switch (requestCode) {

    case 1: {//from  w  w w  .java2  s. com
        if (resultCode == RESULT_OK && data != null) {
            setMicIcon(false, false);
            ArrayList<String> text = data.getStringArrayListExtra(RecognizerIntent.EXTRA_RESULTS);
            editTextForGoogle.setText(text.get(0));
            txt.setText("Status: Done!");
        }
        break;
    }
    }
}

From source file:com.meetingninja.csse.MainActivity.java

@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    super.onActivityResult(requestCode, resultCode, data);

    if (requestCode == 3)
        frag_notes.populateList();//w w  w. jav  a 2  s  . c  o m

    if (requestCode == VOICE_RECOGNITION_REQUEST_CODE && resultCode == RESULT_OK) {
        ArrayList<String> thingsYouSaid = data.getStringArrayListExtra(RecognizerIntent.EXTRA_RESULTS);
        if (thingsYouSaid.contains("meetings")) {
            selectItem(DrawerLabel.MEETINGS.getPosition());
        } else if (thingsYouSaid.contains("groups")) {
            selectItem(DrawerLabel.GROUPS.getPosition());
        } else if (thingsYouSaid.contains("notes")) {
            selectItem(DrawerLabel.NOTES.getPosition());
        } else if (thingsYouSaid.contains("profile")) {
            selectItem(DrawerLabel.PROFILE.getPosition());
        } else if (thingsYouSaid.contains("tasks")) {
            selectItem(DrawerLabel.TASKS.getPosition());
        } else if (thingsYouSaid.contains("projects")) {
            selectItem(DrawerLabel.PROJECTS.getPosition());
        } else if (thingsYouSaid.contains("contacts")) {
            selectItem(DrawerLabel.CONTACTS.getPosition());
        }
    }
}

From source file:com.ferid.app.notetake.MainActivity.java

@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {

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

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

        //capitalize the first letter
        spokenText = capitalizeFirstLetter(spokenText);
        //now append the spoken text
        appendNote(spokenText);//from   ww  w  .j a v a2s  .  c  om

    }

    super.onActivityResult(requestCode, resultCode, data);
}

From source file:com.neighbor.ex.tong.ui.activity.MainActivity2Activity.java

@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    super.onActivityResult(requestCode, resultCode, data);
    switch (requestCode) {
    case REQ_CODE_SPEECH_INPUT:
        if (resultCode == RESULT_OK && null != data) {
            ArrayList<String> result = data.getStringArrayListExtra(RecognizerIntent.EXTRA_RESULTS);
            String regex = "[0-9]{4}";
            String resultData = result.get(0);
            if (resultData.matches(regex)) {
                inputCarNo.postDelayed(new Runnable() {
                    @Override//w ww.  j ava 2  s.  co m
                    public void run() {
                        inputCarNo.showDropDown();
                    }
                }, 500);
                inputCarNo.setText(resultData);
                inputCarNo.setSelection(inputCarNo.getText().length());
            }
        }
        break;
    case PICK_CAMERA_REQUEST:
        if (resultCode == RESULT_OK && null != data) {
            String carNum = data.getStringExtra("carNum");
            if (carNum.equalsIgnoreCase("??")) {
                Toast.makeText(MainActivity2Activity.this,
                        "?? .  ? .", Toast.LENGTH_SHORT).show();
                inputCarNo.setText("");
            } else {
                String resultCarNo = data.getStringExtra("resultCarNo");
                Log.d("hts", "resultCarNo : " + resultCarNo);
                resultCarNo = resultCarNo.substring(resultCarNo.length() - 4, resultCarNo.length());
                inputCarNo.postDelayed(new Runnable() {
                    @Override
                    public void run() {
                        inputCarNo.showDropDown();
                    }
                }, 500);
                inputCarNo.setText(resultCarNo);
                inputCarNo.setSelection(inputCarNo.getText().length());
            }
        }
        break;
    }
}