change photo profile Firebase Auth Android

0

Can you change the photo directly by pressing a button, or is it better to take out another fragment? After choosing the photo I have no idea how to continue.

public void changephoto(View view){
    final int PICK_IMAGE_REQUEST = 71;

    Intent intent = new Intent();
    intent.setType("image/*");
    intent.setAction(Intent.ACTION_GET_CONTENT);
    startActivityForResult(Intent.createChooser(intent,"Select Picture"), PICK_IMAGE_REQUEST);



    FirebaseUser user = FirebaseAuth.getInstance().getCurrentUser();

    UserProfileChangeRequest profileUpdates = new UserProfileChangeRequest.Builder()
            .setPhotoUri(Uri.parse(""))//Falta la eleccion de la foto
            .build();

    user.updateProfile(profileUpdates)
            .addOnCompleteListener(new OnCompleteListener<Void>() {
                @Override
                public void onComplete(@NonNull Task<Void> task) {
                    if (task.isSuccessful()) {

                    }
                }
            });
}
    
asked by lujan 20.05.2018 в 19:23
source

1 answer

0
___ erkimt ___ change photo profile Firebase Auth Android ______ qstntxt ___

Can you change the photo directly by pressing a button, or is it better to take out another fragment? After choosing the photo I have no idea how to continue.

FirebaseUser user = FirebaseAuth.getInstance().getCurrentUser();

UserProfileChangeRequest profileUpdates = new UserProfileChangeRequest.Builder()
        .setPhotoUri(Uri.parse("URL_DE_LA_IMAGEN_QUE_QUIERAS_PONER"))
        .build();

user.updateProfile(profileUpdates)
        .addOnCompleteListener(new OnCompleteListener<Void>() {
            @Override
            public void onComplete(@NonNull Task<Void> task) {
                if (task.isSuccessful()) {
                    Log.d(TAG, "User profile updated.");
                }
            }
        });
    
______ ___ azszpr166221

You must modify the user's profile to add the URL of the image, firebase in the documentation you can find it all very detailed, here's an example:

FirebaseUser user = FirebaseAuth.getInstance().getCurrentUser();

UserProfileChangeRequest profileUpdates = new UserProfileChangeRequest.Builder()
        .setPhotoUri(Uri.parse("URL_DE_LA_IMAGEN_QUE_QUIERAS_PONER"))
        .build();

user.updateProfile(profileUpdates)
        .addOnCompleteListener(new OnCompleteListener<Void>() {
            @Override
            public void onComplete(@NonNull Task<Void> task) {
                if (task.isSuccessful()) {
                    Log.d(TAG, "User profile updated.");
                }
            }
        });
    
___
answered by 21.05.2018 в 11:15