Pass an image from an activity to main screen

0

How can I move an image from an activity to another actiivity?

I have an image on my settings screen, I want to send it to my home screen.

I saved it in my sharedPreferences and would like to use the key on my other screen, just like I do with texts.

Activity where I am saving the data (editor.putString ("image", photo);)

public void salvarDados(){
    String usrname = edtEmailSettings.getText().toString();
    String name = edtNameField.getText().toString();
    String phone = edtPhoneField.getText().toString();
    String company = edtCompanySettings.getText().toString();
    String photo = imgProfileImage.toString();
    if(!savelogincheckbox.isChecked()){
        editor.putBoolean("savelogin",true);
        editor.putString("user",usrname);
        editor.putString("nam", name);
        editor.putString("phon", phone);
        editor.putString("company", company);
        editor.putString("image", photo);
        editor.commit();
    }
}

Now I do not know how to get the key ("image") in the other activity, I can get texts and send a setText ().

How to do this with image?

    
asked by anonymous 29.11.2018 / 14:06

1 answer

2

I recommend that you pass your image through Intent , however, before you should convert the image to Bitmap and only then pass it through intent extras

To move your image from the first activity to the one you want, you need to do this:

In your Settings Activity:

imageView.buildDrawingCache();
Bitmap bitmap = imageView.getDrawingCache();

Intent intent = new Intent(this, ActivityAlvo.class);
intent.putExtra("BitmapImage", bitmap);

Recovering in the Target Activity:

Bitmap bitmap = (Bitmap) intent.getParcelableExtra("BitmapImage");

Note: The correct one would be to save this image somewhere else and recover by passing the path of it.

I hope you have helped.

    
29.11.2018 / 16:17