I am trying to disable touchscreen input for the user. This will be used to try and get a camera app to work underwater (where the phone is kept inside a diving case) to prevent conductive sea water touches.
I did come across suggestions on how to do it in android SDK:
getWindow().setFlags(WindowManager.LayoutParams.FLAG_NOT_TOUCHABLE, WindowManager.LayoutParams.FLAG_NOT_TOUCHABLE);
However, I cant seem to find ways to call this API in .NET MAUI. The only documentation I could find is this: https://learn.microsoft.com/en-us/dotnet/api/android.app.activity.window?view=xamarin-android-sdk-13
Which doesnt explain anything at all.
You can try to put the following code in the Platforms\Android\MainActivity.cs's OnCreate method or the OnResume Method.
protected override void OnResume()
{
base.OnResume();
this.Window.SetFlags(Android.Views.WindowManagerFlags.NotTouchable,Android.Views.WindowManagerFlags.NotTouchable);
}
Or you can call this method in the share project. Such as:
public void DisableTouchable()
{
#if ANDROID
Microsoft.Maui.ApplicationModel.Platform.CurrentActivity.Window.SetFlags(Android.Views.WindowManagerFlags.NotTouchable,Android.Views.WindowManagerFlags.NotTouchable);
#endif
}