Bug 51854 - [Forms/Android] Soft keyboard does not appear for entry field on first page shown by app.
Summary: [Forms/Android] Soft keyboard does not appear for entry field on first page s...
Status: RESOLVED ANSWERED
Alias: None
Product: Forms
Classification: Xamarin
Component: Android (show other bugs)
Version: 2.3.3
Hardware: PC Windows
: Normal normal
Target Milestone: ---
Assignee: Bugzilla
URL:
Depends on:
Blocks:
 
Reported: 2017-01-27 20:17 UTC by AJZ Tangoe
Modified: 2018-03-14 18:16 UTC (History)
8 users (show)

Tags: android ac
Is this bug a regression?: ---
Last known good build:

Notice (2018-05-24): bugzilla.xamarin.com is now in read-only mode.

Please join us on Visual Studio Developer Community and in the Xamarin and Mono organizations on GitHub to continue tracking issues. Bugzilla will remain available for reference in read-only mode. We will continue to work on open Bugzilla bugs, copy them to the new locations as needed for follow-up, and add the new items under Related Links.

Our sincere thanks to everyone who has contributed on this bug tracker over the years. Thanks also for your understanding as we make these adjustments and improvements for the future.


Please create a new report on Developer Community or GitHub with your current version information, steps to reproduce, and relevant error messages or log files if you are hitting an issue that looks similar to this resolved bug and you do not yet see a matching new report.

Related Links:
Status:
RESOLVED ANSWERED

Description AJZ Tangoe 2017-01-27 20:17:07 UTC
On Android the soft keyboard does not open when the first page opened in an app contains an Entry control for which focus has been set.

On Android (works in iOS and UWP) using the below app when the "passcode" page is first opened when the app starts the soft keyboard does not open.  But when the same page is opened later on in the app the soft keyboard does appear.

I have tried this in both the latest stable release (2.3.3.180) and the latest pre-release (2.3.4.184-pre1) and neither works properly.

using System;
using Xamarin.Forms;

namespace XamFormsSoftKeyboardIssue
{
    class SamplePasscodePage : ContentPage
    {
        private readonly Entry _passcodeEntry;

        public SamplePasscodePage(Action openAnotherPage)
        {
            _passcodeEntry = new Entry
            {
                Keyboard = Keyboard.Numeric,
                IsPassword = true,
                VerticalOptions = LayoutOptions.Start,
                HorizontalOptions = LayoutOptions.Fill,
            };

            var button = new Button
            {
                Text = "Open Another Page",
                Command = new Command(openAnotherPage)
            };

            Content = new StackLayout
            {
                Children =
                {
                    _passcodeEntry,
                    button
                }
            };
        }

        protected override void OnAppearing()
        {
            base.OnAppearing();
            _passcodeEntry.Focus();
        }

        protected override void OnDisappearing()
        {
            _passcodeEntry.Unfocus();
            base.OnDisappearing();
        }
    }

    public class App : Application
    {
        public App()
        {
            OpenPasscodePage();
        }

        private void OpenPasscodePage()
        {
            MainPage = new SamplePasscodePage(OpenAnotherPage);
        }

        private void OpenAnotherPage()
        {
            MainPage = new ContentPage
            {
                Content = new Button
                {
                    Text = "Open Passcode Page Again",
                    Command = new Command(OpenPasscodePage),
                    VerticalOptions = LayoutOptions.Center,
                    HorizontalOptions = LayoutOptions.Center
                }
            };
        }
    }
}
Comment 1 John Hardman 2017-06-22 11:15:10 UTC
Probably another symptom of the same bug - on Android with the focus on an Entry and the soft keyboard visible, tap the Task Switcher (a.k.a. Overview) button to show the carousel of running apps. Tap the same app to return to it. The page will be displayed again, the focus will still be on the Entry, but the soft keyboard is now hidden even though focus in on an Entry.

(problem exists in XF 2.3.4)
Comment 2 Namyslaw Szymaniuk 2017-09-06 06:35:36 UTC
God damn it... I'm just fighting with this issue - I need to focus entry on page start, and it's working fine, for all pages, except first navigation stack page, where the focus is just beeing ommited. Actually there is something done behind, because it's needed to tap Android *back* button two times, to leave the app, when the focus is being requested, and only one *back* button tap, where there wasn't requested focus.

However there is no keyboard appeared. I've also tried to write platform specific service, to "force" keyboard show, but it's also not working.

No iOS there is no issue - no matter, if we are requesting focus on page start (no matter, if it's first navigation stack page, second, third etc.). Issue exist only on Android for first page.

Any plan for fix this issue in some of next release? For me it's still not fixed in latest pre release *2.4.0.269-pre2*.
Comment 3 Namyslaw Szymaniuk 2018-01-10 11:18:30 UTC
ANYONE!? After 4 months, there is still no answer/update/fix?
At *2.5.0.122203* it's still not working, without such "hacky" and "shtty" workarounds - https://forums.xamarin.com/discussion/100354/entry-focus-not-working-for-android
Comment 4 Namyslaw Szymaniuk 2018-03-14 08:07:34 UTC
I've just opened github issue for that - https://github.com/xamarin/Xamarin.Forms/issues/2094
Comment 5 Samantha Houts [MSFT] 2018-03-14 18:16:22 UTC
Please follow the GitHub issue for updates. Thanks!