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

ZXingScannerViewRenderer was causing the app to crash if the view was inside a ContentView #1060

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

seansparkman
Copy link

If the ZXingScannerView was inside of a ContentView instead of a ContentPage, the application would crash by throwing a Java.Lang.NullPointerException. The Context passed to ZXingScannerViewRenderer via the constructor was actually a ContextThemeWrapper which does not inherit from Activity. Therefore when it was cast in the call of the constructor of ZXingScannerView in the renderer on Android, a null would be passed for a context instead.

Fixes: #943

… inside a ContentView

If the `ZXingScannerView` was inside of a `ContentView` instead of a `ContentPage`, the application would crash by throwing a `Java.Lang.NullPointerException`. The `Context` passed to `ZXingScannerViewRenderer` via the constructor was actually a `ContextThemeWrapper` which does not inherit from `Activity`. Therefore when it was cast in the call of the constructor of `ZXingScannerView` in the renderer on Android, a `null` would be passed for a context instead.

Fixes: Redth#943
@bidy
Copy link

bidy commented Jun 30, 2023

I experience a similar issue. The ZXingScannerView is inside a ScrollView in a ContentPage. The application crashes for the reason described above.
The issue does not occur, when the ScrollView is removed.
The bug fix proposed above fixes the issue, although I would recommend zxingSurface = new ZXingSurfaceView(Context.GetActivity(), formsView.Options); rather than the proposed one.

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

Successfully merging this pull request may close these issues.

Java.Lang.NullPointerException When Attempting to Initialize ContentPage with Scanner
2 participants