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

Can't take photo on Android 8, 9, 10 when another photo application is installed #291

Open
3 tasks done
bmarsaud opened this issue Apr 11, 2024 · 2 comments
Open
3 tasks done
Milestone

Comments

@bmarsaud
Copy link
Contributor

bmarsaud commented Apr 11, 2024

Bug Report

Problem

What is expected to happen?

The image capture request should resolve successfully while another photo taking application is installed on the device.

What does actually happen?

The image capture request is considered as cancelled (Error code 3) while the user has successfully taken the photo.

Information

To reproduce, you need to have another photo taking application installed (Like Professional HD Camera for instance) so that Android is showing you an intent to chose the application to use.
You don't even need to use this other application, the problem occurs whether you use the default camera app or not.

The problem occurs on Android 8, 9 and 10.
It does not occur on Android 11, 12 and 13.

I don't know for versions prior to 8.

This is a duplicate of #139, but as it's tagged as Invalid, I'm recreating the issue here with more information.

Command or Code

Nothing special here, a simple :

navigator.device.capture.captureImage(onCaptureSuccess, onCaptureError);

will do.

Environment, Platform, Device

Devices : Android SDK Emulator and various physical devices on Android 8, 9, 10
Dev env OS : Ubuntu 22.04 LTS

Version information

Cordova : 12.0.0
Cordova Platforms : Android 12.0.1, iOS 6.3.0

Checklist

  • I searched for existing GitHub issues
  • I updated all Cordova tooling to most recent version
  • I included all the necessary information above
@bmarsaud
Copy link
Contributor Author

bmarsaud commented Apr 11, 2024

public void onActivityResult(int requestCode, int resultCode, final Intent intent) {

The resultCode received by the activity result is indeed Activity.RESULT_CANCELED, but the file at the imageUri location contains well the photo taken.

I also noticed that the intent is null, which is not the case when you only have one photo taking app installed. We can descrimine on that to handle this case. The intent is always null when it has been cancelled.

@bmarsaud
Copy link
Contributor Author

FYI, the intent being cancelled in the first place seems to be due to the AndroidLaunchMode (https://medium.com/mindorks/android-launch-mode-787d28952959) being set to singleInstance.

Using singleTask instead fix the issue, the intent is no longer considered as cancelled and everything is working properly.

@breautek breautek added this to the 6.0.0 milestone Dec 3, 2024
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