Android源代码分析之拍照、图片、录音、视频和音频功能
 
//选择图片 requestCode 返回的标识
Intent innerIntent = new Intent(Intent.ACTION_GET_CONTENT); //"android.intent.action.GET_CONTENT"
innerIntent.setType(contentType); //查看类型 String IMAGE_UNSPECIFIED = "image/*";
Intent wrapperIntent = Intent.createChooser(innerIntent, null);
((Activity) context).startActivityForResult(wrapperIntent, requestCode);
 
//视频
Intent innerIntent = new Intent(Intent.ACTION_GET_CONTENT);
innerIntent.setType(contentType); //String VIDEO_UNSPECIFIED = "video/*";
Intent wrapperIntent = Intent.createChooser(innerIntent, null);
((Activity) context).startActivityForResult(wrapperIntent, requestCode);
 
//加入音频
Intent innerIntent = new Intent(Intent.ACTION_GET_CONTENT);
innerIntent.setType(contentType); //String VIDEO_UNSPECIFIED = "video/*";
Intent wrapperIntent = Intent.createChooser(innerIntent, null);
((Activity) context).startActivityForResult(wrapperIntent, requestCode);
 
//录音
Intent intent = new Intent(Intent.ACTION_GET_CONTENT);
intent.setType(ContentType.AUDIO_AMR); //String AUDIO_AMR = "audio/amr";
intent.setClassName("com.android.soundrecorder",
"com.android.soundrecorder.SoundRecorder");
((Activity) context).startActivityForResult(intent, requestCode);
 
//拍摄视频
int durationLimit = getVideoCaptureDurationLimit(); //SystemProperties.getInt("ro.media.enc.lprof.duration", 60);
Intent intent = new Intent(MediaStore.ACTION_VIDEO_CAPTURE);
intent.putExtra(MediaStore.EXTRA_VIDEO_QUALITY, 0);
intent.putExtra(MediaStore.EXTRA_SIZE_LIMIT, sizeLimit);
intent.putExtra(MediaStore.EXTRA_DURATION_LIMIT, durationLimit);
startActivityForResult(intent, REQUEST_CODE_TAKE_VIDEO);
 
//拍照 REQUEST_CODE_TAKE_PICTURE 为返回的标识
Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE); //"android.media.action.IMAGE_CAPTURE";
intent.putExtra(MediaStore.EXTRA_OUTPUT, Mms.ScrapSpace.CONTENT_URI); // output,Uri.parse("content://mms/scrapSpace");
startActivityForResult(intent, REQUEST_CODE_TAKE_PICTURE);

 

=======================================================================

      谈谈程序猿发展的5个出路    
         程序猿接私活的几个注意事项

      从IT菜鸟变“骨干”的10个建议  
      就业市场最急需的10大类IT人才

      怎样成为软件设计师混合型人才   应届生就业。“IT行业”平均收入最高

      找程序猿做老公的10个优点  
         学Android软件开发的就业钱景分析

      给IT新兵职业发展的15个建议  
      程序猿成美2014收入最高职业

=======================================================================

Android源代码分析之拍照、图片、录音、视频和音频功能的更多相关文章

  1. Swift实现iOS录音与播放音频功能

    作用AVPLayer:可以用来播放在线及本地音视频AVAudioSession:音频会话,主要用来管理音频设置与硬件交互使用时需要导入 #import <AVFoundation/AVFound ...

  2. Cordova Android源代码分析系列一(项目总览和CordovaActivity分析)

    版权声明:本文为博主offbye西涛原创文章.未经博主同意不得转载. https://blog.csdn.net/offbye/article/details/31776833 PhoneGap/Co ...

  3. (转)Android学习-使用Async-Http实现图片压缩并上传功能

    (转)Android学习-使用Async-Http实现图片压缩并上传功能 文章转载自:作者:RyaneLee链接:http://www.jianshu.com/p/940fc7ba39e1 让我头疼一 ...

  4. uni-app实现图片和视频上传功能

    使用uni-app实现点击上传,既可以上传视频,有可以上传图片,图片预览,删除图片和视频功能,最终效果如下.uni-app里面没有提供同时上传视频和图片这个插件,只能靠自己手写,  1.页面布局 通过 ...

  5. The jQuery HTML5 Audio / Video Library (jQuery jPlayer插件给你的站点增加视频和音频功能)

    http://jplayer.org/ The jQuery HTML5 Audio / Video Library jPlayer is the completely free and open s ...

  6. Android源代码分析-资源载入机制

    转载请注明出处:http://blog.csdn.net/singwhatiwanna/article/details/23387079 (来自singwhatiwanna的csdn博客) 前言 我们 ...

  7. android 如何获取手机的图片、视频、音乐

    在android 开发中,很多时候,我们会需要调用到用户本机的照片.视频或者是音乐让用户选择,来进行我们APP对应的操作. button.setOnClickListener(new OnClickL ...

  8. Android源代码分析之Framework的MediaPlayer

    在Android中MediaPlayer用来播放音频和视频文件,在这里分析下在Framework层中MediaPlayer是怎样调用的.MediaPlayer的代码位于:./frameworks/ba ...

  9. 手机端file限制只能选择图片、视频、音频,直接打开摄像头拍照或录像

    限制只能选择图片 <input type="file" accept="image/*"> 限制只能选择视频 <input type=&quo ...

随机推荐

  1. @DataProvider的应用

    代码中经常有一些数据需要维护,但是每次都写在一个class或者methods中,维护起来是个麻烦事: 这里引入@DataProvider的思想,建一个DataProvider的方法,让我们需要维护的数 ...

  2. 以普通用户启动的Vim如何保存需要root权限的文件

    在Linux上工作的朋友很可能遇到过这样一种情况,当你用Vim编辑完一个文件时,运行:wq保存退出,突然蹦出一个错误: E45: 'readonly' option is set (add ! to ...

  3. SPOJ-394-ACODE - Alphacode / dp

    ACODE - Alphacode #dynamic-programming Alice and Bob need to send secret messages to each other and ...

  4. maven-surefire-plugin的forkMode分析

    Maven运行测试用例时,是通过调用maven的surefire插件并fork一个子进程来执行用例的.forkmode属性中指明是要为每个测试创建一个进程,还是所有测试在同一个进程中完成. <p ...

  5. 几款必备LINUX的命令行神器

    Dstat & sar iostat, vmstat, ifstat 三合一的工具,用来查看系统性能(我在<性能调优攻略>中提到过那三个xxstat工具). 官方网站:http:/ ...

  6. Windows下查看占用端口程序

    配置shadowsocks,发现本地1080端口被占用,当然更改没有占用的端口即可.当然还得查找下什么程序占用的.无奈,看了下115浏览器占用此端口,浏览器不能管啊,你懂得!!! Windows查找下 ...

  7. 006——数组(六)array_fill()array_filter()array_flip()array_key_exists()array_keys()

    <?php /*数组(六)array_fill()array_filter()array_flip()array_key_exists()array_keys() */ /*1.array_fi ...

  8. A网页高度随B内容而自然变化兼容各种浏览器

    今天是星期一,昨天又没有睡好,眼睛干干的,还有点痛疼,于是不想干啥.但是心里又不觉得过意不去,浪费时间呀,考虑再三把自己前面实现的一个东西发了上来.算是今天的功劳,没有过多的文字描述,纯粹是贴图片和代 ...

  9. ZooKeeper和Dubbo

    前言 Dubbo是阿里开源的一个分布式服务框架,但是阿里内部用的却是HSF(High-speed Service Framework).下面看看怎么使用吧. Zookeeper Dubbo是个RPC调 ...

  10. HTML条件注释判断浏览器版本命令

    <!--[if !IE]><!--> 除IE外都可识别 <!--<![endif]--> <!--[if IE]> 所有的IE可识别 <![ ...