[英]In Android how to add user_photos permission to get the facebook album photos?
[英]Reading user photos in android
尝试读取用户拍摄的照片列表并将其显示在imageview中。 为了简单起见,现在尝试仅显示一个。 到目前为止,具有以下代码:
Cursor cc = this.getContentResolver().query(MediaStore.Images.Media.EXTERNAL_CONTENT_URI, null, null, null,null);
这使我在光标中得到了一些数据,cc.getCount()似乎很有意义(在我拍照时上升了一位,等等)。 但是,我根本无法在imageView中显示内容,什么也没有显示。
我尝试过此操作(s_id是上方光标的图片ID,第一个返回的列):
Uri u;
u = Uri.withAppendedPath(MediaStore.Images.Thumbnails.EXTERNAL_CONTENT_URI, "" + s_id);
im.setImageURI(u);
还尝试了这个:
Bitmap b = BitmapFactory.decodeFile(u.getPath());
im.setImageBitmap(b);
没有工作 救命?
PS。 没有错误显示在任何地方。
这是让用户选择图像并将其显示在imageview中的另一种方法。
此代码将允许用户浏览文件以从图库中选择图像:
Intent picture = new Intent(Intent.ACTION_GET_CONTENT);
picture.setType("image/*");
startActivityForResult(picture, YOUR_CODE);
然后,在onActivityResult方法中,您可以使用数据设置imageview:
public void onActivityResult(int requestCode, int resultCode, Intent data){
//This is where you can use the data from the previous intent to set the image view
Uri uri = data.getData();
im.setImageURI(uri); //where im is your imageview
}
请查看此链接以获取更详细的答案。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.