Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Showing a dialog on Android when app is just installed seems not to work (any more) #36

Open
1 task
john-dalsgaard opened this issue Jan 30, 2023 · 1 comment

Comments

@john-dalsgaard
Copy link

Description

I have a Xamarin app where I show dialogs in a few places. By coincidence we discovered that showing a dialog right after the app has been installed doesn't work. I'm pretty sure that has worked before....

Steps to Reproduce

  1. In an app create a simple dialog and a button to open it using code like this.
            var dlg = new ConfirmDialog
            {
                Title = AppResources.ConfirmCancelLoginHeading,
                Message = AppResources.ConfirmCancelLoginText,
                OkButton = AppResources.ConfirmCancelLoginContinueButton,
                CancelButton = AppResources.ConfirmCancelLoginCancelButton
            };
            return await Dialog.Instance.ShowAsync(dlg);

In this case it is a simple XAML dialog looking like this:

<?xml version="1.0" encoding="UTF-8" ?>
<extra:DialogView
    xmlns="http://xamarin.com/schemas/2014/forms"
    xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
    xmlns:extra="clr-namespace:AiForms.Dialogs.Abstractions;assembly=AiForms.Dialogs"
    xmlns:custom="clr-namespace:Angler.Views.CustomControls"
    UseCurrentPageLocation="False"
    OverlayColor="#80000000"
    ProportionalWidth="0.9"
    HorizontalLayoutAlignment="Center"
    VerticalLayoutAlignment="Center"
    x:Name="Dialog" 
    x:Class="Angler.Views.CustomControls.ConfirmDialog"
    x:DataType="custom:ConfirmDialog">
    <ContentView BindingContext="{x:Reference Dialog}">
        <StackLayout BackgroundColor="White" Padding="10">
            <Label Text="{Binding Title}"
                   Padding="0,10"
                   Style="{StaticResource ConfirmDialogHeading}"></Label>
            <ScrollView BackgroundColor="Transparent">
                <Label Text="{Binding Message}"
                       Style="{StaticResource ConfirmDialogText}"></Label>
            </ScrollView>
            <Grid>
                <Button Text="{Binding OkButton}"
                        Grid.Column="0"
                        Clicked="OkButtonClicked"
                        Padding="1"/>
                <Button Text="{Binding CancelButton}"
                        Grid.Column="1"
                        Clicked="CancelButtonClicked"
                        Padding="1"/>
            </Grid>
        </StackLayout>
    </ContentView>
</extra:DialogView>

with this "code behind":

using AiForms.Dialogs.Abstractions;

namespace Angler.Views.CustomControls
{
    public partial class ConfirmDialog : DialogView
    {
        public string Title { get; set; }
        public string Message { get; set; }
        public string OkButton { get; set; }
        public string CancelButton { get; set; }
        public ConfirmDialog()
        {
            InitializeComponent();
        }

        void OkButtonClicked(object sender, System.EventArgs e)
        {
            DialogNotifier.Complete();
        }
        void CancelButtonClicked(object sender, System.EventArgs e)
        {
            DialogNotifier.Cancel();
        }

    }
}
  1. The ShowAsync() method just never returns...
  2. Now close the app and start it again - and the dialog shows as expected!
  3. Close and remove the app. Install it again - and the dialog doesn't show...

Expected Behavior

That the dialog was shown also right after the app is installed.

Actual Behavior

Code doesn't seem to ever return from the "ShowAsync()" method

Platforms

  • [X ] Android
  • iOS

Basic Information

  • AiForms.Dialogs 1.0.16
  • Xamarin.Forms 5.0.0.2545
  • Android Support Library Version:
  • Affected Devices:
    Emulators and phones
    However, it seems to work Ok on a simulator running API 33. Fails on API 31 and 29 (and others "old").
    The project has Android target set to Android 12.1 (API 32)...

Screenshots

Reproduction Link

Workaround

Only for the confirmation dialogs - I simply don't ask when Android and app has just been installed. But doesn't work for other dialogs.

@john-dalsgaard
Copy link
Author

... also tried on API 32 - and problem is there as well.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant