Java - Wait for a method to execute next instruction

2

I'm doing a CRUD application on Android for the college project. I'm using a ImageButton to select the image to save. The part of selecting the image and getting it stored is working well; but the photo in the view ImageButton does not change.

startActivityForResult(Intent.createChooser(galeria, "Selecione a imagem"), 32);
btimg.setImageBitmap(imagemselecionada2);

So I realized this btimg.setImageBitmap is running before the previous instruction select an image. How would I make it run soh after the startActivity above finishes running?

    
asked by anonymous 17.05.2016 / 21:44

1 answer

0

Good afternoon, man I once had to override the method below, because after the user select the image, Android returns the intent and focus to his activity and performs the method below:

@Override

protected void onActivityResult(int requestCode, int ResultCode, Intent intent){
  if(requestCode == 32){
    if(resultCode == RESULT_OK){

      //seu codigo aqui
      btimg.setImageBitmap(imagemselecionada2);
    }
}}

Maybe it will help you!

    
17.05.2016 / 22:20