Simple example of Android recording and playback function
Simple example of Android recording and playback function
Recently, I have been studying some commonly used functions in Android, such as the implementation of map, photographing, recording and playback, as well as how to realize some sideslip and animation. Today, let's share the implementation of recording and playback. Recording and playback are relatively simple, which can be realized by using Android's internal classes.
1. First look at the interface after operation:
The following three pictures are for entering, recording and playing.
2. Layout file
3 activity class
The recording involves two activities. The first activity is relatively simple. I'll talk about it here. In fact, there is a button. Click to transfer the second activity. After the recording returns, obtain the file name and duration of the recording in the first activity.
First activity part code:
Second activity Code:
Note that you need to capture the return key and handle it. When you click the return key, a status code will be returned to indicate that the recording is not successful.
Thank you for reading, hope to help you, thank you for your support to this site!