Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Take a photo don't work on api 29 #13

Open
remedywu opened this issue Jul 18, 2020 · 5 comments
Open

Take a photo don't work on api 29 #13

remedywu opened this issue Jul 18, 2020 · 5 comments

Comments

@remedywu
Copy link

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.

@aminography
Copy link
Owner

I've tested it on an emulator and multiple devices and seems no problem. What is your test environment?

@remedywu
Copy link
Author

I have put your library on my application. It worked until i published last week.
My application on the store is Quiz Felins.

@aminography
Copy link
Owner

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.

@remedywu
Copy link
Author

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

@aminography
Copy link
Owner

aminography commented Aug 19, 2020

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants