如何从ProfilePictureView获得资料图片在数据库中存储 [英] How to get the profile picture from ProfilePictureView to store in the database
问题描述
我已经成功地整合Facebook登录在我的Android app.So我喜欢显示的姓名,电子邮件和图像用户配置文件数据。
I have successfully integrated facebook login in my android app.So I am displaying user profile data like name,email and picture.
现在我需要存储如姓名,电子邮件和数据库资料图片用户数据。我知道怎么弄的姓名和电子邮件,因为它可以从TextViews得到。 但是我在努力获得的个人资料图片。
Now I need to store user data such as name,email and profile picture in database. I know how to get the name and email since it can be get from TextViews. But I am struggling to get the profile picture.
使用ProfilePictureView显示的资料图片。
我试图把该图像转换上ProfilePictureView到字节数组,但它不工作。(通常这适用于ImageView的,Imagebuttons,,但它不与ProfilePictureView工作)
I tried to convert that image on ProfilePictureView to byte array, but it is not working.(Normally this works with ImageView ,Imagebuttons, but it is not working with ProfilePictureView)
pic.setProfileId(user.getId());
ImageView imageView = (ImageView)pic.getChildAt(0);
Bitmap bmp = ((BitmapDrawable) imageView.getDrawable()).getBitmap();
image_ = convertImageToByte(bmp); //image_ is a byte[]
private byte[] convertImageToByte(Bitmap bitmap) {
ByteArrayOutputStream stream = new ByteArrayOutputStream();
bitmap.compress(Bitmap.CompressFormat.JPEG, 90, stream);
return stream.toByteArray();
}
我越来越喜欢这个,而不是真实的个人资料图片的图像。
I am getting an image like this instead of the real profile picture.
反正是有存储图像? (像一个链接来获取资料图片存储,所以我可以用在以后的链接检索图像)
谢谢你。
Is there anyway to store the image? (like a link to get the profile picture to store so I can retrieve the image using the link at later time) Thanks.
推荐答案
试试这个。它为我工作
private ProfilePictureView profilepic;
在onCreate方法类型:
In OnCreate Method type:
profilepic = (ProfilePictureView) findViewById(R.id.<profilepicture id>);
profilepic.setProfileId(id of user (string));
希望它能帮助
这篇关于如何从ProfilePictureView获得资料图片在数据库中存储的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!