在Android 1.5访问视频和照片+ [英] Accessing Videos AND Photos on Android 1.5 +

查看:131
本文介绍了在Android 1.5访问视频和照片+的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

所以我想,让用户选择一个特定的介质与我的使用这里介绍的方法,Android应用程序: <一href="http://stackoverflow.com/questions/550905/access-pictures-from-pictures-app-in-my-android-app">http://stackoverflow.com/questions/550905/access-pictures-from-pictures-app-in-my-android-app

So I'm trying to allow the user to pick a particular piece of media with my Android Application using the method described here: http://stackoverflow.com/questions/550905/access-pictures-from-pictures-app-in-my-android-app

它的伟大工程,除了事实,我可以貌似只有视频或照片的同时选择present用,而不是两个用户。有没有好的办法做到这一点有:

It works great, except for the fact that I can seemingly only choose between either Video or Photo to present the user with, not both at the same time. Is there a good way to do this with:

startActivityForResult(新   意图(Intent.ACTION_PICK,   android.provider.MediaStore.Images.Media.INTERNAL_CONTENT_URI)   SELECT_IMAGE);

startActivityForResult(new Intent(Intent.ACTION_PICK, android.provider.MediaStore.Images.Media.INTERNAL_CONTENT_URI), SELECT_IMAGE);

谢谢!

推荐答案

我已经使用了好几次。最好的办法是这样的:

I've used this several times. The best way is something like:

Intent mediaChooser = new Intent(Intent.ACTION_GET_CONTENT);
//comma-separated MIME types
mediaChooser.setType("video/*, images/*");
startActivityForResult(mediaChooser, 1);

即使这是不完全准确的,它一直很好的一切,我在使用它,它会打开一个画廊式的活动与每一个图片/视频用户的画廊的缩略图列表。返回的意图 onActivityResult()有一个名为DATA一个额外的,这将是一个内容:// URI所选择的媒体

Even if this isn't perfectly accurate, it has worked fine in everything I've used it in. It will open up a Gallery-esque activity with a thumbnail list of every picture/video in the user's gallery. The returned intent to onActivityResult() has an extra called "DATA" which will be a content:// URI to the selected media.

编辑:哎呀,得到的URI你真的想调用所选择的媒体的getData()上被传递到onActivityResult的意图()

oops, to get the URI to the selected media you actually want to call getData() on the Intent that gets passed to onActivityResult()

这篇关于在Android 1.5访问视频和照片+的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆