Android开源 - 安卓音频录制

ezla8599 8年前
   <h2>效果图</h2>    <p><img alt="" src="https://simg.open-open.com/show/560cf357a4ef105b6fc4a8d40f86ee96.png"></p>    <h2>使用</h2>    <p>1 - 在<code>AndroidManifest.xml 中设置权限 </code><a href="/misc/goto?guid=4959676719568383091">request for them in Android 6.0+</a></p>    <pre>  <code class="language-java"><uses-permission android:name="android.permission.RECORD_AUDIO"/>  <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/></code></pre>    <p>2 - 打开记录的Activity</p>    <pre>  <code class="language-java">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();</code></pre>    <p>3 -  等待结果</p>    <pre>  <code class="language-java">@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          }      }  }</code></pre>    <h2>导入工程</h2>    <p>在 <code>app/build.gradle加入下行:</code></p>    <pre>  <code class="language-java">repositories {    maven {      url "https://jitpack.io"    }  }    dependencies {    compile 'com.github.adrielcafe:AndroidAudioRecorder:0.0.3'  }</code></pre>    <p> </p>