Android拍照、录像、录音代码范例
2010-07-15 20:54:00 来源:WEB开发网File out = new File(strImgPath);
if (!out.exists()) {
out.mkdirs();
}
out = new File(strImgPath, fileName);
strImgPath = strImgPath + fileName;//该照片的绝对路径
Uri uri = Uri.fromFile(out);
imageCaptureIntent.putExtra(MediaStore.EXTRA_OUTPUT, uri);
imageCaptureIntent.putExtra(MediaStore.EXTRA_VIDEO_QUALITY, 1);
startActivityForResult(imageCaptureIntent, RESULT_CAPTURE_IMAGE);
}
/**
* 拍摄视频
*/
private void videoMethod() {
Intent intent = new Intent(MediaStore.ACTION_VIDEO_CAPTURE);
intent.putExtra(MediaStore.EXTRA_VIDEO_QUALITY, 0);
startActivityForResult(intent, REQUEST_CODE_TAKE_VIDEO);
}
/**
* 录音功能
*/
private void soundRecorderMethod() {
Intent intent = new Intent(Intent.ACTION_GET_CONTENT);
intent.setType("audio/amr");
startActivityForResult(intent, RESULT_CAPTURE_RECORDER_SOUND);
}
/**
* 提示信息
* @param text
* @param duration
*/
private void showToast(String text, int duration) {
Toast.makeText(ProblemReport.this, text, duration).show();
}
}
http://haogood.5d6d.com/thread-557-1-1.html
更多精彩
赞助商链接