做好了拍照的功能,增加了上传录制摄的功能。
部分代码:
private void takePhoto () { // Checks for camera app available Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE); if (!IntentChecker.isAvailable(mainActivity, intent, new String[]{PackageManager.FEATURE_CAMERA})) { mainActivity.showMessage(R.string.feature_not_available_on_this_device, ONStyle.ALERT); return; } // Checks for created file validity File f = StorageHelper.createNewAttachmentFile(mainActivity, MIME_TYPE_IMAGE_EXT); if (f == null) { mainActivity.showMessage(R.string.error, ONStyle.ALERT); return; } attachmentUri = FileProviderHelper.getFileProvider(f); intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION); intent.putExtra(MediaStore.EXTRA_OUTPUT, attachmentUri); startActivityForResult(intent, TAKE_PHOTO); }
private void takeVideo () {
Intent takeVideoIntent = new Intent(MediaStore.ACTION_VIDEO_CAPTURE);
if (!IntentChecker.isAvailable(mainActivity, takeVideoIntent, new String[]{PackageManager.FEATURE_CAMERA})) {
mainActivity.showMessage(R.string.feature_not_available_on_this_device, ONStyle.ALERT);
return;
}