diff --git a/samples/Forms/LibVLCSharp.Forms.MediaElement/LibVLCSharp.Forms.MediaElement.Sample.Android/Resources/Resource.designer.cs b/samples/Forms/LibVLCSharp.Forms.MediaElement/LibVLCSharp.Forms.MediaElement.Sample.Android/Resources/Resource.designer.cs index c16b36613f3caf33c41ccbb82e2838f282988194..9589a7c0b15cf7d8041fb1bccabcefcc49642ff0 100644 --- a/samples/Forms/LibVLCSharp.Forms.MediaElement/LibVLCSharp.Forms.MediaElement.Sample.Android/Resources/Resource.designer.cs +++ b/samples/Forms/LibVLCSharp.Forms.MediaElement/LibVLCSharp.Forms.MediaElement.Sample.Android/Resources/Resource.designer.cs @@ -2,7 +2,6 @@ //------------------------------------------------------------------------------ // // This code was generated by a tool. -// Runtime Version:4.0.30319.42000 // // Changes to this file may cause incorrect behavior and will be lost if // the code is regenerated. diff --git a/samples/Forms/LibVLCSharp.Forms.Sample.Android/Resources/Resource.designer.cs b/samples/Forms/LibVLCSharp.Forms.Sample.Android/Resources/Resource.designer.cs index 73c847287f8371d0cda37c324336124188cd6eb7..c8a4b55494ee0602c2c844aaf9555b1a82dac701 100644 --- a/samples/Forms/LibVLCSharp.Forms.Sample.Android/Resources/Resource.designer.cs +++ b/samples/Forms/LibVLCSharp.Forms.Sample.Android/Resources/Resource.designer.cs @@ -2,7 +2,6 @@ //------------------------------------------------------------------------------ // // This code was generated by a tool. -// Runtime Version:4.0.30319.42000 // // Changes to this file may cause incorrect behavior and will be lost if // the code is regenerated. diff --git a/samples/LibVLCSharp.Android.Sample/Resources/Resource.Designer.cs b/samples/LibVLCSharp.Android.Sample/Resources/Resource.Designer.cs index 52dfa14e5cf7e855508c23e7a27d1d748ea74e01..47d57d3325aee596d9679998d784a66b1eb1c272 100644 --- a/samples/LibVLCSharp.Android.Sample/Resources/Resource.Designer.cs +++ b/samples/LibVLCSharp.Android.Sample/Resources/Resource.Designer.cs @@ -2,7 +2,6 @@ //------------------------------------------------------------------------------ // // This code was generated by a tool. -// Runtime Version:4.0.30319.42000 // // Changes to this file may cause incorrect behavior and will be lost if // the code is regenerated. diff --git a/src/LibVLCSharp.Forms/Platforms/Android/Platform.cs b/src/LibVLCSharp.Forms/Platforms/Android/Platform.cs index 9cc363e861dc9a15b5af0e5de6f91735d43b8c98..62f25de68cce5a85c83e2dcd66dbde57a902222b 100644 --- a/src/LibVLCSharp.Forms/Platforms/Android/Platform.cs +++ b/src/LibVLCSharp.Forms/Platforms/Android/Platform.cs @@ -23,34 +23,34 @@ namespace LibVLCSharp.Forms.Platforms.Android set => CurrentActivity.SetTarget(value); } - public void OnActivityCreated(Activity activity, Bundle savedInstanceState) + public void OnActivityCreated(Activity? activity, Bundle? savedInstanceState) { Activity = activity; } - public void OnActivityDestroyed(Activity activity) + public void OnActivityDestroyed(Activity? activity) { } - public void OnActivityPaused(Activity activity) + public void OnActivityPaused(Activity? activity) { Activity = activity; } - public void OnActivityResumed(Activity activity) + public void OnActivityResumed(Activity? activity) { Activity = activity; } - public void OnActivitySaveInstanceState(Activity activity, Bundle outState) + public void OnActivitySaveInstanceState(Activity? activity, Bundle? outState) { } - public void OnActivityStarted(Activity activity) + public void OnActivityStarted(Activity? activity) { } - public void OnActivityStopped(Activity activity) + public void OnActivityStopped(Activity? activity) { } } @@ -73,7 +73,13 @@ namespace LibVLCSharp.Forms.Platforms.Android { lifecycleListener = new ActivityLifecycleContextListener(); LifecycleListener = lifecycleListener; - activity.Application.RegisterActivityLifecycleCallbacks(lifecycleListener); + var app = activity.Application; + if (app is null) + { + throw new InvalidOperationException("The given activity is not linked to an Application instance (activity.Application is null)"); + } + + app.RegisterActivityLifecycleCallbacks(lifecycleListener); } lifecycleListener.Activity = activity; } diff --git a/src/LibVLCSharp.Forms/Platforms/Android/SystemUI.cs b/src/LibVLCSharp.Forms/Platforms/Android/SystemUI.cs index fcf637a241cb926382e312765c7de618a28a7090..efe1c502433eda7e2925995bd810ee1ff3109cd8 100644 --- a/src/LibVLCSharp.Forms/Platforms/Android/SystemUI.cs +++ b/src/LibVLCSharp.Forms/Platforms/Android/SystemUI.cs @@ -1,6 +1,4 @@ -using Android.App; -using Android.Views; -using Java.Lang; +using Android.Views; using LibVLCSharp.Forms.Platforms.Android; using LibVLCSharp.Forms.Shared; using Xamarin.Forms; @@ -12,21 +10,23 @@ namespace LibVLCSharp.Forms.Platforms.Android { public void ShowSystemUI() { - if (Platform.Activity == null) + var decorView = Platform.Activity?.Window?.DecorView; + if (decorView == null) return; - Platform.Activity.Window.DecorView.SystemUiVisibility = + decorView.SystemUiVisibility = (StatusBarVisibility)(SystemUiFlags.LayoutStable | SystemUiFlags.LayoutFullscreen); } public void HideSystemUI() { - if (Platform.Activity == null) + var decorView = Platform.Activity?.Window?.DecorView; + if (decorView == null) return; - Platform.Activity.Window.DecorView.SystemUiVisibility = - Platform.Activity.Window.DecorView.SystemUiVisibility | + decorView.SystemUiVisibility = + decorView.SystemUiVisibility | (StatusBarVisibility)(SystemUiFlags.ImmersiveSticky | SystemUiFlags.Fullscreen | SystemUiFlags.HideNavigation | diff --git a/src/LibVLCSharp.Forms/Platforms/Android/VideoViewRenderer.cs b/src/LibVLCSharp.Forms/Platforms/Android/VideoViewRenderer.cs index 7f47ac242c676dd462f0f979356be5bb50ff73f9..e5ce287482728b99af0fb2c29364094129cac079 100644 --- a/src/LibVLCSharp.Forms/Platforms/Android/VideoViewRenderer.cs +++ b/src/LibVLCSharp.Forms/Platforms/Android/VideoViewRenderer.cs @@ -35,7 +35,7 @@ namespace LibVLCSharp.Forms.Platforms.Android { if (Control == null) { - SetNativeControl(new LibVLCSharp.Platforms.Android.VideoView(Context)); + SetNativeControl(new LibVLCSharp.Platforms.Android.VideoView(Context!)); e.NewElement.MediaPlayerChanging += OnMediaPlayerChanging; if (Control!.MediaPlayer != e.NewElement.MediaPlayer)