Detect non system input method

By April 13, 2016Blog

On Android developers cannot define whether the input field supports non standards/custom keyboards. This might be an issue for secured applications, like mobile banking, or any line of business apps. What can be done then is to at least notify the user that this is the case and he should be careful not to use such input methods when logging in and use only the system default ones.

The code to check that is:

InputMethodManager methodManager = (InputMethodManager)this.GetSystemService (Context.InputMethodService);

foreach (var inputMethodInfo in methodManager.EnabledInputMethodList)
{
    if (inputMethodInfo.Id.Equals (Settings.Secure.GetString (ContentResolver, Settings.Secure.DefaultInputMethod)) == false)
    {
        if ((inputMethodInfo.ServiceInfo.ApplicationInfo.Flags & ApplicationInfoFlags.System) == 0)
        {
            // we found non default input method, so show the error toast and return;
        }
    }
}

Happy coding.