app/src/main/java/com/voices/ui/activity/SpeechActivity.java
/**
     * Handle the result after Speech being detected
     *
     * @param requestCode
     * @param resultCode
     * @param data
     */
Handle the result after Speech being detected
@param requestCode
@param resultCode
@param data
Handle the result after Speech being detected @param requestCode @param resultCode @param data
@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) {
                    final ArrayList<String> result = data.getStringArrayListExtra(RecognizerIntent.EXTRA_RESULTS);
                    final String speechInput = result.get(0);
                    tv_user_speaks_data.setText(speechInput);
                    new Handler().postDelayed(new Runnable() {
                        @Override
                        public void run() {
                            Intent resultIntent = new Intent();
                            resultIntent.putExtra(INTENT_KEY_SPEECH_INPUT_RESULT, speechInput);
                            setResult(RESULT_OK, resultIntent);
                            finish();
                            overridePendingTransition(android.R.anim.fade_in, android.R.anim.fade_out);
                        }
                    }, 1200);
                }
                break;
            }
        }
    }
@ 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 ) { final ArrayList < String > result = data . getStringArrayListExtra ( RecognizerIntent . EXTRA_RESULTS ) ; final String speechInput = result . get ( 0 ) ; tv_user_speaks_data . setText ( speechInput ) ; new Handler ( ) . postDelayed ( new Runnable ( ) { @ Override public void run ( ) { Intent resultIntent = new Intent ( ) ; resultIntent . putExtra ( INTENT_KEY_SPEECH_INPUT_RESULT , speechInput ) ; setResult ( RESULT_OK , resultIntent ) ; finish ( ) ; overridePendingTransition ( android . R . anim . fade_in , android . R . anim . fade_out ) ; } } , 1200 ) ; } break ; } } }
Handle the result after Speech being detected
 @param requestCode
 @param resultCode
 @param data
Handle the result after Speech being detected @param requestCode @param resultCode @param data