summaryrefslogtreecommitdiff
path: root/Xamarin.Forms.Platform.Android
diff options
context:
space:
mode:
Diffstat (limited to 'Xamarin.Forms.Platform.Android')
-rw-r--r--Xamarin.Forms.Platform.Android/KeyboardManager.cs10
1 files changed, 7 insertions, 3 deletions
diff --git a/Xamarin.Forms.Platform.Android/KeyboardManager.cs b/Xamarin.Forms.Platform.Android/KeyboardManager.cs
index bfe65d13..eb89731b 100644
--- a/Xamarin.Forms.Platform.Android/KeyboardManager.cs
+++ b/Xamarin.Forms.Platform.Android/KeyboardManager.cs
@@ -14,14 +14,15 @@ namespace Xamarin.Forms.Platform.Android
if (Forms.Context == null)
throw new InvalidOperationException("Call Forms.Init() before HideKeyboard");
+ if (inputView == null)
+ throw new ArgumentNullException(nameof(inputView) + " must be set before the keyboard can be hidden.");
+
using (var inputMethodManager = (InputMethodManager)Forms.Context.GetSystemService(Context.InputMethodService))
{
- IBinder windowToken = null;
-
if (!overrideValidation && !(inputView is EditText || inputView is TextView || inputView is SearchView))
throw new ArgumentException("inputView should be of type EditText, SearchView, or TextView");
- windowToken = inputView.WindowToken;
+ IBinder windowToken = inputView.WindowToken;
if (windowToken != null)
inputMethodManager.HideSoftInputFromWindow(windowToken, HideSoftInputFlags.None);
}
@@ -32,6 +33,9 @@ namespace Xamarin.Forms.Platform.Android
if (Forms.Context == null)
throw new InvalidOperationException("Call Forms.Init() before ShowKeyboard");
+ if (inputView == null)
+ throw new ArgumentNullException(nameof(inputView) + " must be set before the keyboard can be shown.");
+
using (var inputMethodManager = (InputMethodManager)Forms.Context.GetSystemService(Context.InputMethodService))
{
if (inputView is EditText || inputView is TextView || inputView is SearchView)