Sirs, good morning!
I thank you for the comments, I came here to inform you that I have been able to resolve my doubts.
The code below follows, I'm sure it will help others who are starting out just like me.
first activity:
public class MainActivity extends AppCompatActivity {
Uri image;
ImageView img;
Bitmap bitmap_ok;
Button btnImagem1,btnImagem2 ;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
btnImagem1 = findViewById(R.id.btnImagem1);
btnImagem1.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
Intent photoPickerIntent = new Intent(Intent.ACTION_PICK, MediaStore.Images.Media.EXTERNAL_CONTENT_URI);
photoPickerIntent.setType("image/*");
startActivityForResult(photoPickerIntent, 1);
}
});
img = findViewById(R.id.imageView);
btnImagem2 = findViewById(R.id.btnImagem2);
btnImagem2.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
passarImagem();
}
});
}
private void passarImagem() {
img = findViewById(R.id.imageView);
Drawable drawable = img.getDrawable();
Bitmap bitmap = ((BitmapDrawable)drawable).getBitmap();
ByteArrayOutputStream stream = new ByteArrayOutputStream();
bitmap.compress(Bitmap.CompressFormat.JPEG, 100, stream);
byte[] imageInByte = stream.toByteArray();
Intent intent = new Intent(MainActivity.this,SegundaTela.class);
intent.putExtra("imagem",imageInByte);
startActivity(intent);
finish();
}
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
if (requestCode == 1 && resultCode == RESULT_OK){
image = data.getData();
try {
bitmap_ok = MediaStore.Images.Media.getBitmap(getContentResolver(),image);
ByteArrayOutputStream stream = new ByteArrayOutputStream();
bitmap_ok.compress(Bitmap.CompressFormat.JPEG, 100, stream);
img.setImageBitmap(bitmap_ok);
}catch (IOException e){
e.printStackTrace();
}
}
}
}
second activy:
public class SegundaTela extends AppCompatActivity {
ImageView imgs;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_segunda);
try {
Bundle bundle = getIntent().getExtras();
if (bundle != null){
try {
byte[] imageInByte = bundle.getByteArray("imagem");
Bitmap bmp = BitmapFactory.decodeByteArray(imageInByte,0,imageInByte.length);
imgs = findViewById(R.id.imageView22);
imgs.setImageBitmap(bmp);
}catch (Exception e){}
}
}catch (Exception e){
Toast.makeText(this,""+e,Toast.LENGTH_SHORT).show();
e.printStackTrace();
}
}
}