我米做这需要我名单上的手机的SD卡所有可用的图像的应用程序。
我想查询ContentResolver的方式,即
光标图像= getContentResolver()查询(Images.Media.EXTERNAL_CONTENT_URI,新的String [] {Images.Media._ID,Images.Media.DATA,Images.Media.DISPLAY_NAME} ,NULL,NULL,NULL);
但没有任何结果。请问有什么办法可以让列表或者如果多数民众赞成不可能的,那么是否有任何可能的意图(如PICK),通过它我可以让用户选择一个文件,然后访问用户选择??
Helppppp家伙...
解决方案您可以使用库活动选择图像,是这样的:
意向意图=新的意图();
intent.setType(图像/ *);
intent.setAction(Intent.ACTION_GET_CONTENT);
startActivityForResult(Intent.createChooser(意向,选择图片),SELECT_IMAGE);
在回调该活动的文件的uri将在意图参数
I m making an application which requires me to list all the images available on the SD-Card of the phone.
i tried querying the ContentResolver way i.e.
Cursor image = getContentResolver().query(Images.Media.EXTERNAL_CONTENT_URI, new String[]{Images.Media._ID,Images.Media.DATA,Images.Media.DISPLAY_NAME}, null, null, null);
but without any result. Is there any way i can get the list or if thats not possible then is there any possible intent (e.g. PICK) by which i can allow the user to select a file and then access the path of the file the user selected??
Helppppp guys...
解决方案You could use the gallery activity to select images, something like this:
Intent intent = new Intent();
intent.setType("image/*");
intent.setAction(Intent.ACTION_GET_CONTENT);
startActivityForResult(Intent.createChooser(intent, "Select Picture"),SELECT_IMAGE);
in the callback for the activity the file uri will be in the intent parameter