Android. Открыть фото из галереи в новом intent
в Android разработке я новичок, в связи с чем возник вопрос. При нажатии на кнопку btnGal я выбираю фото из галереи.Как можно сделать так чтобы фото, которое я выбираю из галереи отображалось в новом intent? Подскажите что нужно сделать(сохранить imageView в какую-нибудь дерикторию и потом его выгружать на другом intent или можно как-то по-другому) Просьба обьяснить новичку как это сделать.
MainActivity
public class MainActivity extends AppCompatActivity {
ImageButton btnGal;
ImageButton btnSha;
ImageView imageView;
static final int GALLERY_REQUEST = 1;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
requestWindowFeature(Window.FEATURE_NO_TITLE);
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
setContentView(R.layout.activity_main);
btnGal = (ImageButton) findViewById(R.id.btnGal);
btnSha = (ImageButton) findViewById(R.id.btnSha);
imageView = (ImageView) findViewById(R.id.imageView);
btnGal.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent photoPickerIntent = new Intent(Intent.ACTION_PICK);
photoPickerIntent.setType("image/*");
startActivityForResult(photoPickerIntent, GALLERY_REQUEST);
}
});
}
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent imageReturnedIntent) {
super.onActivityResult(requestCode, resultCode, imageReturnedIntent);
ImageView imageView = (ImageView) findViewById(R.id.imageView);
switch(requestCode) {
case GALLERY_REQUEST:
if(resultCode == RESULT_OK){
Uri selectedImage = imageReturnedIntent.getData();
//imageView.setImageURI(selectedImage);
Intent intent = new Intent(MainActivity.this, EditorActivity.class);
startActivityForResult(intent,1);
}
}
}
}