调用android系统摄像头,指定路径

u010300542 2014-03-01 12:58:28
通过intent调用系统摄像头,来进行拍照和拍摄视频,
intent.putExtra(MediaStore.EXTRA_OUTPUT, fileUri);
这个命令可以指定照片的储存路径,为什么到了拍摄视频是为什么就无效了,不能指定路径了?
...全文
239 2 打赏 收藏 转发到动态 举报
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
u010300542 2014-03-09
  • 打赏
  • 举报
回复
你书写的方法应该是,从手机系统储存所拍摄视频的路径处,又copy了一份到自己制定的地方,这的确是一种方法;不过我还想知道:intent.putExtra(MediaStore.EXTRA_OUTPUT, fileUri)通过这个方法制定路径为什么会失效?(经过我的测试,这个方法在有的手机上能行,有的却不行)
ns_235 2014-03-03
  • 打赏
  • 举报
回复
这个是视频的Intent---Intent mIntent = new Intent( MediaStore.ACTION_VIDEO_CAPTURE); startActivityForResult(mIntent, VIDEO_RESULT); 这个是要重写的方法 protected void onActivityResult(int requestCode, int resultCode, Intent data) { // TODO Auto-generated method stub super.onActivityResult(requestCode, resultCode, data); if (requestCode == VIDEO_RESULT) { if (resultCode == Activity.RESULT_OK) { try { videoPath = Environment.getExternalStorageDirectory() .getAbsolutePath() + "/cpicvideo/";// 设置图片的保存路径 File file = new File(videoPath); if (!file.exists()) { System.out.println("no file"); file.mkdirs(); } else { File files[] = file.listFiles(); for (int i = 0; i < files.length; i++) { files[i].delete();// 删除文件夹内所有的图片 } } videoPath = Environment.getExternalStorageDirectory() .getAbsolutePath() + "/cpicvideo/" + System.currentTimeMillis() + ".mp4";// 设置图片的保存路径 AssetFileDescriptor videoAsset = getContentResolver() .openAssetFileDescriptor(data.getData(), "r"); FileInputStream fis = videoAsset.createInputStream(); File tmpFile = new File(videoPath); FileOutputStream fos = new FileOutputStream(tmpFile); byte[] buf = new byte[1024]; int len; while ((len = fis.read(buf)) > 0) { fos.write(buf, 0, len); } fis.close(); fos.close(); } catch (IOException io_e) { // TODO: handle error } } } }

80,351

社区成员

发帖
与我相关
我的任务
社区描述
移动平台 Android
androidandroid-studioandroidx 技术论坛(原bbs)
社区管理员
  • Android
  • yechaoa
  • 失落夏天
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧