Skip to content

Commit

Permalink
ZXingScannerViewRenderer was causing the app to crash if the view was…
Browse files Browse the repository at this point in the history
… 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
  • Loading branch information
seansparkman committed Dec 8, 2022
1 parent f8abca8 commit aefb694
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion ZXing.Net.Mobile.Forms/ZXingScannerViewRenderer.android.cs
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ protected override async void OnElementChanged(ElementChangedEventArgs<ZXingScan
}
}

zxingSurface = new ZXingSurfaceView(Context as Activity, formsView.Options);
zxingSurface = new ZXingSurfaceView(Context, formsView.Options);
zxingSurface.LayoutParameters = new LayoutParams(LayoutParams.MatchParent, LayoutParams.MatchParent);

base.SetNativeControl(zxingSurface);
Expand Down

0 comments on commit aefb694

Please sign in to comment.