mohan
mohan

Reputation: 13165

How to stop media recorder and go to another activity in android

How do I stop the media recorder and go to another activity in android? I have set setMaxduration in media recorder. How do I check if maxduration has been reached? I have to stop the media recorder and go to another activity.

Thanks

Upvotes: 1

Views: 806

Answers (1)

c05mic
c05mic

Reputation: 558

You may use the onInfo listener to listen for the event and then start the other activity.

Use the following code snippet:

mediaRecorder = new MediaRecorder(); 
//... all your setup stuff ... 

mediaRecorder.setOnInfoListener(new MediaRecorder.OnInfoListener(){ 
    @Override 
    public void onInfo(MediaRecorder mr, int what, int extra) { 

        if(what == MediaRecorder.MEDIA_RECORDER_INFO_MAX_DURATION_REACHED ) { 
           startActivity(new Intent(this.getApplicationContext(), ANOTHERACTIVITY.class)); 
        } 
    } 
}); 

Hope this helps!!

Upvotes: 2

Related Questions