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. 在Android的webview中定制js的alert,confirm和prompt对话框的方
  3. Android应用程序避免Context相关的内存泄露的方法
  4. Android使用getIdentifier()获取资源Id的方法
  5. java基础学习总结之IO流和equal()方法
  6. Android(安卓)1.5 1.6 2.0 2.1 2.2 2.3 3.0的区别概要
  7. onSaveInstanceState和onRestoreInstanceState
  8. Android初级教程_获取Android控件的宽和高
  9. Android(安卓)Test(未完工)

随机推荐

  1. Android(安卓)之父裁员 30%:开发者如何避
  2. 10个经典的Android开源应用项目
  3. android 那些事---主线程是线程不安全的
  4. Android笔记-MultiThreading in Android(
  5. Android的内存机制和常见泄漏情形
  6. Android高手进阶教程(二十)---Android中
  7. 30个高质量并且免费的Android图标【Andro
  8. Android高手进阶教程(四)之----Android(
  9. Android高手进阶教程(四)之----Android(
  10. Android内核与主线linux内核的比较(Androi