Code example for SpeechRecognizer

Methods: cancel

0
        pd.setIndeterminate(true);
        pd.setCancelable(true);
        pd.setOnCancelListener(new OnCancelListener() {
            @Override 
            public void onCancel(DialogInterface dialog) {
                sr.cancel();
                onEndOfSpeech(); 
            } 
        }); 
 
        pd.show();
        sr.startListening(intent);
 
        speechStarted = System.currentTimeMillis();
    } 
 
    @Override 
    public void onBeginningOfSpeech() { 
        System.err.println("beginning");
 
    }