summaryrefslogtreecommitdiff
path: root/Xamarin.Forms.Platform.Android
diff options
context:
space:
mode:
authorOddbjørn Bakke <oddbjorn.bakke@gmail.com>2016-08-17 09:26:27 (GMT)
committerRui Marinho <me@ruimarinho.net>2016-08-17 09:26:27 (GMT)
commitcb2bcdb84c45dad15cf470b798069f2ab301bf19 (patch)
tree66eab2f8e0ab7ff46b4b1d6cce04c7f12411f4a9 /Xamarin.Forms.Platform.Android
parente488f7f3189d5bafecf36f79c4fb1862d662350b (diff)
downloadxamarin-forms-cb2bcdb84c45dad15cf470b798069f2ab301bf19.zip
xamarin-forms-cb2bcdb84c45dad15cf470b798069f2ab301bf19.tar.gz
xamarin-forms-cb2bcdb84c45dad15cf470b798069f2ab301bf19.tar.bz2
[Android] Fix for NullReferenceException when using the wrong activit… (#286)beta-2.3.2-pre2
* [Android] Fix for NullReferenceException when using the wrong activity type. On using FormsApplicationActivity or FormsAppCompatActivity as base Activity in a SplashScreen. A NullReferenceException will be thrown in the KeyboardManager. Added InvalidOperationException with "Forms.Init()" message instead, if the Forms.Context is null. * Fixed indentation
Diffstat (limited to 'Xamarin.Forms.Platform.Android')
-rw-r--r--Xamarin.Forms.Platform.Android/KeyboardManager.cs6
1 files changed, 6 insertions, 0 deletions
diff --git a/Xamarin.Forms.Platform.Android/KeyboardManager.cs b/Xamarin.Forms.Platform.Android/KeyboardManager.cs
index db47857..bfe65d1 100644
--- a/Xamarin.Forms.Platform.Android/KeyboardManager.cs
+++ b/Xamarin.Forms.Platform.Android/KeyboardManager.cs
@@ -11,6 +11,9 @@ namespace Xamarin.Forms.Platform.Android
{
internal static void HideKeyboard(this AView inputView, bool overrideValidation = false)
{
+ if (Forms.Context == null)
+ throw new InvalidOperationException("Call Forms.Init() before HideKeyboard");
+
using (var inputMethodManager = (InputMethodManager)Forms.Context.GetSystemService(Context.InputMethodService))
{
IBinder windowToken = null;
@@ -26,6 +29,9 @@ namespace Xamarin.Forms.Platform.Android
internal static void ShowKeyboard(this AView inputView)
{
+ if (Forms.Context == null)
+ throw new InvalidOperationException("Call Forms.Init() before ShowKeyboard");
+
using (var inputMethodManager = (InputMethodManager)Forms.Context.GetSystemService(Context.InputMethodService))
{
if (inputView is EditText || inputView is TextView || inputView is SearchView)