2012-11-12 32 views
0

我正在尝试从Mediastore.Images.Media图像检索图像,我总是让光标为空。请建议如何解决问题。在此先感谢从Mediastore

Uri contenturi = Images.Media.getContentUri("phoneStorage"); 
    String[] mprojection = { MediaStore.Images.Media.DATA }; 
    String mselection = null; 
    String[] mselectionArgs = null; 
    String msortOrder ="date_added DESC"; 
    Cursor mcursor = managedQuery(contenturi, mprojection, mselection, mselectionArgs, msortOrder); 

当我检查它说,mcursor为空,我试图改变的URI到外部存储也试图与任何排序顺序。但仍然返回null。请帮助

+0

做ü想从画廊的形象? –

+0

是啊,我希望从画廊 –

+0

http://stackoverflow.com/questions/10473823/android-get-image-from-gallery-into-imageview导入的照片 –

回答

0

哥们试试这个代码,

Intent intent = new Intent(); 
intent.setType("image/*"); 
intent.setAction(Intent.ACTION_GET_CONTENT);  
startActivityForResult(Intent.createChooser(intent,getResources().getString(R.string.accept)),1); 

现在只需使用onActivityResult方法从库获取图像。