-4

My app includes tts and stt. My app works by voice command.

So, I want to use the back button. When the user click back button, the app should go to the first step, but it didn't.

My code;

public class SpeechActivity extends FragmentActivity implements Const {

    protected PowerManager.WakeLock mWakeLock; 
    private SpeechRecognizer mSpeechRecognizer; 
    private Intent mSpeechRecognizerIntent;
    private SpeechRecognitionListener srListener;
    private Vocalizer vocalizer;
    private Object lastTtsContext = null;
.......
@Override
    public void onBackPressed() {

        speakToDisabled(Const.COMMAND_WARNING_MESSAGE); 
        super.onBackPressed();
        try {
            mSpeechRecognizer.wait();
        } catch (InterruptedException e) {
            speakToDisabled(Const.COMMAND_BYE);
        }
    }
Daniel Nugent
  • 43,104
  • 15
  • 109
  • 137
Gül
  • 19
  • 3
  • 1
    Your question is not clear, please be specific and more detailed in what problem you face? – Skynet May 05 '15 at 07:10
  • 1
    Edit your code properly, and explain what exactly you want the back button to do, go to the first activity, or what? – A B May 05 '15 at 07:10

2 Answers2

1

Delete or comment this line, because it finish your current activity.

super.onBackPressed();
RediOne1
  • 10,389
  • 6
  • 25
  • 46
1

Calling super.onBackPressed() finishes your Activity, so if you want to make your "first step" inside this Activity, comment this line.

Ircover
  • 2,406
  • 2
  • 22
  • 42