1

I have a program, need to compare string input via voice input. However, it gets nothing although it shows on the result list. what is the problem? sample code:

 protected void onActivityResult(int requestCode, int resultCode, Intent data) {
        if (requestCode == 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);
            mList.setAdapter(new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1,matches));
            for(int i=0;i<matches.size();i++){
                if(matches.get(i).equals("添加")){
                    Toast.makeText(getApplicationContext(), "get", Toast.LENGTH_LONG);
                }
            }
        }
        super.onActivityResult(requestCode, resultCode, data);
    }

the code above toast nothing although "添加" is already shows on the result list.

panda
  • 1,344
  • 3
  • 14
  • 35

0 Answers0