我正在构建一个记录几分钟并保存到应用程序文件夹的应用程序,现在我需要一种方法来从文件夹中获取所有 .3gp 文件并将它们发布到服务器,我不知道如何在 android 中搜索类型文件,搜索了这里的帖子,但没有运气。
这是我用来保存录音的代码,也许你们可以帮我看看...
public void record_file(){
UserFunctions userFunction = new UserFunctions();
// Get Global Vars from Database
DatabaseHandler db = new DatabaseHandler(getApplicationContext());
HashMap<String, String> global = db.getGlobalVars();
id = global.get("id");
record = global.get("record");
Log.v("RECORD", "Id: " + id);
JSONObject json = userFunction.listenVARIABLES(id);
int duration = Integer.parseInt(record_minutes) * 60 * 1000;
if (record == "1") {
try {
// Save file local to app
mFileName = path + i + "_record_" + id_ + ".3gp";
mRecorder = new MediaRecorder();
mRecorder.setAudioSource(MediaRecorder.AudioSource.MIC);
mRecorder.setOutputFormat(MediaRecorder.OutputFormat.THREE_GPP);
mRecorder.setOutputFile(mFileName);
mRecorder.setAudioEncoder(MediaRecorder.AudioEncoder.AMR_NB);
mRecorder.setMaxDuration(duration);
try {
mRecorder.prepare();
} catch (IOException e) {
Log.e("AUDIO_RECORDER", "prepare() failed");
}
mRecorder.start();
} catch (JSONException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}