首页 > 系统 > Android > 正文

Android中简单调用图片、视频、音频、录音和拍照的方法

2019-10-23 20:22:32
字体:
来源:转载
供稿:网友

本文实例讲述了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);

希望本文所述对大家Android程序设计有所帮助。


注:相关教程知识阅读请移步到Android开发频道。
发表评论 共有条评论
用户名: 密码:
验证码: 匿名发表