Closed kevkov closed 2 years ago
Possibly the main thread bit is a red herring. Investigating further.
It appears getting DisplayAlert to work correctly on Android is dependent on how main thread execution is is setup and how the async computation is performed. Don't really understand why but documented it with this app: https://github.com/kevkov/FabDisplayAlert
Not tested on iOS yet.
Description
FabulousContacts' attempt to display an alert on the main thread with DisplayAlert throws an exception and stops message processing. The problem appears to be with how execution on the main thread is done.
Steps to reproduce
+
toolbar button to add a contact.SAVE
toolbar button.Expected behaviour
A data validation alert is shown.
Actual behaviour
No alert is shown. The app stops responding to user input, except the back button. Logcat shows an exception stacktrace:
The TicTacToe app displays an alert when the game completes and does not suffer this issue. In this case the alert is displayed on the main thread using
Application.Current.Dispatcher.BeginInvokeOnMainThread
. FabulousContacts displays the alert on the main thread usingDevice.InvokeOnMainThreadAsync
.