1. android中的一个隐藏的类:ContentType,其中定义了android支持的mimetype类型   类的路径: com.google.android.mms.ContentType
2. Action为Intent.ACTION_GET_CONTENT的Intent可以设置许多参数,如:   intent.putExtra("crop", "true");
intent.putExtra("outputX", appsWallpaperWidth);
intent.putExtra("outputY", apps_wallpaper_height);
intent.putExtra("aspectX", appsWallpaperWidth);
intent.putExtra("aspectY", apps_wallpaper_height);
intent.putExtra("scale", true);
intent.putExtra("noFaceDetection", true);
intent.putExtra("output", appsWallpaperPath);
intent.putExtra("outputFormat", "JPEG"); 3. 使用startActivityForResult方法启动Intent对应的Activity,可以在原Activity的回调方法onActivityResult方法中拿到返回的数据.返回的数据放在第三个参数data(Intnet类型)中.   使用getData返回一个Uri,再使用context.getContentResolver().openInputStream(uri);可以拿到一个输入流.    //选择图片 requestCode 返回的标识 Intent intent = new Intent(Intent.ACTION_GET_CONTENT); //"android.intent.action.GET_CONTENT" intent.setType(contentType); //查看类型 String IMAGE_UNSPECIFIED = "image/*"; Intent wrapperIntent = Intent.createChooser(intent, null); ((Activity) context).startActivityForResult(wrapperIntent, requestCode); //添加音频 Intent intent = new Intent(Intent.ACTION_GET_CONTENT); intent.setType(contentType); //String VIDEO_UNSPECIFIED = "video/*"; Intent wrapperIntent = Intent.createChooser(intent, null); ((Activity) context).startActivityForResult(wrapperIntent, 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); //视频 Intent intent = new Intent(Intent.ACTION_GET_CONTENT); intent.setType(contentType); //String VIDEO_UNSPECIFIED = "video/*"; Intent wrapperIntent = Intent.createChooser(intent, 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); //拍照 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);
参考: http://www.cnblogs.com/top5/archive/2012/05/04/2482235.html

更多相关文章

  1. android 对话提示框大全
  2. 阻止一进入页面就弹输入法对话框的方法
  3. Android中SQLiteOpenHelper类的onUpgrade方法的作用
  4. Android(安卓)之 ContentProvider 共享数据库-通讯录
  5. 解决方法:Eclipse的 window-->preferences里面没有Android选项
  6. Android(安卓)桌面组件
  7. Android中动态图形的绘制(一)
  8. 浅谈Java中Collections.sort对List排序的两种方法
  9. Python list sort方法的具体使用

随机推荐

  1. Android(安卓)Design Support Library使
  2. android网格连接
  3. Android(安卓)7.1 设置不支持遥控操作?
  4. 安卓按钮有按下去的效果的实现方法
  5. Android中Media Framework浅析(二)——Medi
  6. Android之如何解决右上角不显示3个点的菜
  7. Android开发之EditText属性详解
  8. 【Android开发】完善搜索功能-添加最近查
  9. 【转】Android(安卓)OTA 升级之一:编译升
  10. 《你知道android的MessageQueue.IdleHand