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

using camera more than one time on android #182

Open
figuerres opened this issue Apr 22, 2024 · 2 comments
Open

using camera more than one time on android #182

figuerres opened this issue Apr 22, 2024 · 2 comments

Comments

@figuerres
Copy link

i created a content page with the barcode reader.
on first use it works great.

if i leave the page and come back the camera does not activate and i have to close the app to get it back.

i am trying to see how to solve this but so far i am not able to as i do not know how the android camera control works.
several people have posted with comments but so far i have not been able to make this work.
can someone please help ?

@figuerres
Copy link
Author

just want to add a bit of info in case it helps anyone:

i have a content page that is navigated to why the flyout menu.
first time in the page works perfect.

but if i navigate back to the page the camera preview is closed and i cant scan.
i have tried some code posted here to try and get the camera back and it almost works.
i have just not been able to figure out the right set of commands to send to the device to get the preview back under control.
if the content page could be fully re-initialized or the control ....
the issue is somewhere in how to control the camera but i am at a loss on where to look.
if a switch from the app and back it works. if i close the app and open it that works..... but i need to stay in the app and just allows the user to open the page and go.

@figuerres
Copy link
Author

SOLVED!
credit to @RoyM33-T for the clues to what i had to do!

the current published view and or the Maui Content page / flyout navigation and the android camera do not work well together.
if you have flyout navigation then the Content page is not disposed of and the camera view is left in a state where if you leave the page and later come back it can not open the camera and preview a new image.

the answer with the current code is to use the code from: Camera is not released when using the CameraBarcodeReaderView in xaml #164

create a content page that is using flyout but then have that page invoke a second page that uses the camera view.

the flyout page needs to create its own local copy of the page with the camera view and get rid of that instance when it has the result back.
that keeps the MAUI runtime from reusing the old instance of the view and start over each time.

ideally the camera view control would detect the changes in the state and re-initialize the view.

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

1 participant