What we want to achieve.
In Xamarin.Forms since Visual Studio 2017 (API28), the entire app does not get focus when launching the app. DispatchKeyEvent() function does not take the first ACTION=KEYDOWN, only ACTION=KEYUP.
Prior to API27, the entire app would get focus when the app was launched, so both ACTION=KEYDOWN and ACTION=KEYUP could be obtained.
Due to this difference in behavior, we are having trouble with our previous apps not working in the same way.
Q. Is there any way to give focus to the entire app at app startup even after API28?
Assumptions.
We are developing an Android app in Xamarin.Forms.
We would like to port an old application developed in Visual Studio 2015 (API 27 or lower) to Visual Studio 2017 or later (API 28 or higher).
The target device is an Android terminal with a hardware keyboard (known as a handy terminal).
The app has an initial startup screen with no Entry, Button, etc., so that the user presses the number or arrow keys with the hardware keys on the handy terminal, and the process proceeds by getting the input event key with DispatchKeyEvent().
Comparison by API.
For easy comparison, I created and tested a blank Xamarin.Forms app in Visual Studio 2017.
The hardware keyboard part works the same with an external Bluetooth keyboard, etc.
(API27)
When built with API27 (Android 8.1), the entire app (StackLayout section) gets focus when the app is launched, and when the hardware keyboard is pressed, key events are taken for both action=ACTION_DOWN/action=ACTION_UP.
(when the app is launched.)
(API28)
If I build with API 28 (Android 9) or later, the entire app (StackLayout area) does not get focus when the app is launched and you cannot get key events with action=ACTION_DOWN when the hardware keyboard is pressed. only can be retrieved.
It is an image that the entire application receives focus with ACTION_DOWN and only ACTION_UP can be acquired by the application.
If I build with API 28 (Android 9) or later, the entire app (StackLayout area) does not get focus when the app is launched and you cannot get key events with action=ACTION_DOWN when the hardware keyboard is pressed. only can be retrieved.
(when the app is launched.)
(When D-pad down is pressed)
I have read the Android development documentation and other documentation, but there were no changes regarding focus in API 28 (Android 9). Earlier API26 (Andorid 8.0) described a change in the focus specification, but it does not match the phenomenon.
Can anyone help me with a solution?
Best regards.