English 中文(简体)
查阅1.5 + 的视频和照片
原标题:Accessing Videos AND Photos on Android 1.5 +

So I m trying to allow the user to pick a particular piece of media with my Android Application using the method described here: Access pictures from Pictures app in my android app

它发挥了巨大作用,但我似乎只能选择视频或照片,向用户介绍,而不是同时介绍。 这样做有好办法:

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

感谢!

最佳回答

我多次使用。 最好的办法是:

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

即便这种粗金字不准确,它在我手里使用的一切物品中都做了罚款。 它将开展美术馆活动,在用户席上列出每个照片/图像。 返回到<条码>的主动性Res(>)中,另有一个称为“DATA”的字句,即向选定的媒体提供内容http:// URI。

EDIT: oops, to have the URI to the selected media, 你实际上想打电话getData ( on the Intent that have received to on actativeResult()

问题回答

Kivy - 最为容易的方式是产生选择一个媒体的意图,将其限制在视频上:

Intent pickMedia = new Intent(Intent.ACTION_GET_CONTENT);
pickMedia.setType("video/*");
startActivityForResult(pickMedia,12345);

注——12345是,你很抱歉,你需要倾听要求,以便你能够寄送你需要的任何信息。

那么,你还需要开展同样的活动,以听从这一意图中解救胎儿:

    @Override
    public void onActivityResult(int requestCode, int resultCode, Intent data) {
        super.onActivityResult(requestCode, resultCode, data);
        if (requestCode == 12345) {
            if (resultCode == Activity.RESULT_OK) {
                Uri selectedVideoLocation = data.getData();

                // Do something with the data...
            } 

        }
    }

冷静

intent = new Intent(Intent.ACTION_PICK, android.provider.MediaStore.Images.Media.EXTERNAL_CONTENT_URI);
startActivityForResult(intent, 1);

引言

Intent intent = new Intent(Intent.ACTION_GET_CONTENT);
intent.setType("*/*");
startActivityForResult(intent, 101);




相关问题
Android - ListView fling gesture triggers context menu

I m relatively new to Android development. I m developing an app with a ListView. I ve followed the info in #1338475 and have my app recognizing the fling gesture, but after the gesture is complete, ...

AsyncTask and error handling on Android

I m converting my code from using Handler to AsyncTask. The latter is great at what it does - asynchronous updates and handling of results in the main UI thread. What s unclear to me is how to handle ...

Android intent filter for a particular file extension?

I want to be able to download a file with a particular extension from the net, and have it passed to my application to deal with it, but I haven t been able to figure out the intent filter. The ...

Android & Web: What is the equivalent style for the web?

I am quite impressed by the workflow I follow when developing Android applications: Define a layout in an xml file and then write all the code in a code-behind style. Is there an equivalent style for ...

TiledLayer equivalent in Android [duplicate]

To draw landscapes, backgrounds with patterns etc, we used TiledLayer in J2ME. Is there an android counterpart for that. Does android provide an option to set such tiled patterns in the layout XML?

Using Repo with Msysgit

When following the Android Open Source Project instructions on installing repo for use with Git, after running the repo init command, I run into this error: /c/Users/Andrew Rabon/bin/repo: line ...

Android "single top" launch mode and onNewIntent method

I read in the Android documentation that by setting my Activity s launchMode property to singleTop OR by adding the FLAG_ACTIVITY_SINGLE_TOP flag to my Intent, that calling startActivity(intent) would ...

From Web Development to Android Development

I have pretty good skills in PHP , Mysql and Javascript for a junior developer. If I wanted to try my hand as Android Development do you think I might find it tough ? Also what new languages would I ...

热门标签