My application involves plenty of sound recording, so I made a widget to be able to record from the Home screen. I have a class Recorder.java where I deal with all the MediaRecorder calls. When recording from the activity, everything works fine. When recording from widget, it records, but doesn't stop recording when it should.
Here is the code I use to stop from the activity:
//r is an instance of Recorder.java
if (r.getState() == Recorder.RECORDING) {
r.stopRecording();
}
When the recording button in the widget is pressed, it starts a service, that checks the recorder state. If r is recording then it stops, if it isn't then it starts recording. This checks works because when its recording and I press it I get a Toast that should appear after it stopped recording, but it never stops recording.
On the service I also use r.stopRecording();
Any ideas what m开发者_开发百科ight be wrong in my code?
please Try to use prepare()
after Stop()
called and at last relase() the MediaRecorder
Object
精彩评论