AndroidAudioRecorder
介绍:
音频录制。
运行效果:
使用说明:
1 - 在AndroidManifest.xml中添加以下权限,并在Android 6.0+中请求它们。
<uses-permission android:name="android.permission.RECORD_AUDIO"/>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
2 - 打开recorder activity
String filePath = Environment.getExternalStorageDirectory() + "/audio.wav";
int color = getResources().getColor(R.color.colorPrimaryDark);
int requestCode = 0;
AndroidAudioRecorder.with(this)
.setFilePath(filePath)
.setColor(color)
.setRequestCode(requestCode)
.record();
3 - 等待结果
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
if (requestCode == RECORD_AUDIO) {
if (resultCode == RESULT_OK) {
// Great! User has recorded and saved the audio file
} else if (resultCode == RESULT_CANCELED) {
// Oops! User has canceled the recording
}
}
}
导入项目
把这个放在app/build.gradle:
repositories {
maven {
url "https://jitpack.io"
}
}
dependencies {
compile 'com.github.adrielcafe:AndroidAudioRecorder:0.0.3'
}
基于
已下载
0