Skip to content

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