Open remedywu opened 4 years ago
I've tested it on an emulator and multiple devices and seems no problem. What is your test environment?
I have put your library on my application. It worked until i published last week. My application on the store is Quiz Felins.
I couldn't reproduce the problem. I have tested it in a couple of situations, but no problem is detected. If possible, share some code or whatever that may help.
There's some code:
choosePhotoHelper = ChoosePhotoHelper.with(this) .asFilePath() .withState(savedInstanceState) .build(new ChoosePhotoCallback
() { @Override public void onChoose(String photo) { if (photo!=null){ Picasso.get().load(new File(photo)).placeholder(R.drawable.image_defaut) .error(R.drawable.image_defaut).fit().into(imageView); } else imageView.setImageResource(0); imageView.setVisibility(View.VISIBLE); } }); super.onActivityResult(requestCode, resultCode, data); if (data != null && data.getData() != null) { if (Configuration.ACTIVELOG) Log.v(TAG,"onActivityResult data:"+data); if (Configuration.ACTIVELOG) Log.v(TAG,"onActivityResult data.getData():"+data.getData()); try { bitmapImage = MediaStore.Images.Media.getBitmap(this.getContentResolver(), data.getData()); if (Configuration.ACTIVELOG) Log.v(TAG,"bitmapImage"+bitmapImage.toString()); } catch (IOException e) { e.printStackTrace(); } } choosePhotoHelper.onActivityResult(requestCode, resultCode, data);
In this sample the data is null when i take a photo and not null when i choose a photo from gallery. I has worked before choose targetSdkVersion 29 and 1.2.0 version
The problem comes from losing data on activity recreation. It's quite normal that data
of resulting intent is null.
To save the state of choosePhotoHelper
during such changes, you should add the following part in addition to .withState(savedInstanceState)
:
@Override
protected void onSaveInstanceState(@NonNull Bundle outState) {
super.onSaveInstanceState(outState);
choosePhotoHelper.onSaveInstanceState(outState);
}
Also, please upgrade the version to 1.3.0
.
I choose the version 1.2.0 but only 1 mode work.
When i "choose from gallery" it work but not "take a photo" since i upgraded with targetSdkVersion 29 and also with the 1.2.0. The data from the intent onActivityResult is null.