Put profile photo in Nav_Header

0

I have a question about creating an App.

I need to put the user's profile photo in my Nav_Header_Tel_Princial.

Ialreadyhaveaprofilescreen,butIneedtousethesameimagefromtheuserprofilescreenformyNAV.

Theprofilescreenisworkingcorrectly,Icansavetheimage,howeverIjustneedtousethesameUriontheotherscreen.

IhavenotyetbeenabletocreateanycodebecauseIhavenoideawhattosearchfor.Ineedalightonhowtoaccomplishthis.

protectedvoidonCreate(BundlesavedInstanceState){        super.onCreate(savedInstanceState);        setContentView(R.layout.activity_settings);

Bundlebundle=newBundle();bundle.putString("foto", resultUri.toString());
    Intent intent = new Intent(SettingsActivity.this, TelaPrincipalActivity.class);
    intent.putExtras(bundle);
    startActivity(intent);

    edtNameField = (EditText) findViewById(R.id.edtName);
    edtPhoneField = (EditText) findViewById(R.id.edtPhone);

    imgProfileImage = (ImageView) findViewById(R.id.imgProfileImage);

    btnBack = (Button) findViewById(R.id.btnBack);
    btnConfirm = (Button) findViewById(R.id.btnConfirm);

    mAuth = FirebaseAuth.getInstance();
    userID = mAuth.getCurrentUser().getUid();
    mCustomerDatabase = FirebaseDatabase.getInstance().getReference().child("Users").child(userID);

    getUserInfo();

    imgProfileImage.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            Intent intent = new Intent(Intent.ACTION_PICK);
            intent.setType("image/*");
            startActivityForResult(intent, 1);
        }
    });

This would be the activity that should receive Uri data.

protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_tela_principal);

    Intent intent = getIntent();
    Bundle bundle = intent.getExtras();

    String foto = bundle.getString("foto");

    btnTest = (Button) findViewById(R.id.BtnTest);
    btnTest.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            openBtnTest();
        }
    });

    edtSearch = (TextView) findViewById(R.id.edtSearch);

    edtSearch.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            search();
        }
    });
    
asked by anonymous 03.09.2018 / 01:25

1 answer

0

If you want to use the photo of the database to display in Nav_Header_Foto you will need to retrieve this Url from the database, and this is done according to your application.  Here is an example of how to retrieve a database value (in this case Firebase RealTime Database) to display when loading activity:

or You also have the example of creating user.

Now, if you just want to move information from one activity to another and I suppose you know something about manipulating View elements (the R.id.findViewById and etc ...)

You can send the data you want through the Bundle .

Just adapt this example to some event in the class of your activity, where urlFoto is the variable already with the url and the intent is used to make the transition between the activities:

 Bundle bundle = new Bundle();
 bundle.putString("foto", urlfoto.toString());

 Intent intent = new Intent(activityAtual.this, proximaActivity.class);
 intent.putExtras(bundle);

 startActivity(intent);

Now in the nextActivity.java you retrieve the values with the following code:

 Intent intent = getIntent();
 Bundle bundle = intent.getExtras();

 String foto = bundle.getString("foto");

Just use your url and set the View element you want.

    
03.09.2018 / 06:37