How to get profile picture from ProfilePictureView for saving in database

I have successfully integrated the facebook login in my Android application. Therefore, I display user profile information such as name, email address and image.

Now I need to store user data such as name, email address and profile picture in the database. I know how to get the name and email address as it can be obtained from TextViews. But I'm trying to get a profile picture.

A profile image is displayed using ProfilePictureView.

I tried converting this image in ProfilePictureView to an array of bytes, but it does not work. (This usually works with ImageView, Imagebuttons , but does not work 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();
    }

, , .

enter image description here

? (, , , , ) .

+1
2

.

private ProfilePictureView profilepic;

OnCreate :

profilepic = (ProfilePictureView) findViewById(R.id.<profilepicture id>);
profilepic.setProfileId(id of user (string));

,

+3

, :

profileImageView = ((ImageView)faceBookProfilePictureView.getChildAt(0));
                            bitmap  = ((BitmapDrawable)profileImageView.getDrawable()).getBitmap();
                              circular.setImageBitmap(bitmap);

"" CircularImageView.

+1

Source: https://habr.com/ru/post/1612021/


All Articles