Quantcast
Channel: Recent Threads — Xamarin Community Forums
Viewing all articles
Browse latest Browse all 204402

Unable to use ACR User Dialogs

$
0
0

Greetings!

I'm new to Xamarin but i had a quite good start, and so far, (almost) everything runs really well.
I wanted to integrate ACR User Dialogs to have a solid dialog service on board (for example for calling dialogs in view models).

So i installed Acr.UserDialogs v6.5.1 via NuGet in both Android and iOS projects (its referenced correctly in both projects)
I registered the Acr package in the android MainActivity, like mentioned in the Github doc:

public class MainActivity : global::Xamarin.Forms.Platform.Android.FormsAppCompatActivity
    {
        protected override void OnCreate(Bundle bundle)
        {

            TabLayoutResource = Resource.Layout.Tabbar;
            ToolbarResource = Resource.Layout.Toolbar;

            base.OnCreate(bundle);
            UserDialogs.Init(this);
            global::Xamarin.Forms.Forms.Init(this, bundle);
            LoadApplication(new App());

        }
    }

I cleaned and rebuild everything, but i'm still unable to call the user dialog.
For debugging purpose (called from a command)

void CheckConnection()
{

            try
            {

                UserDialogs.Instance.Alert("Foo", "Bar");

            } catch (Exception ex)
            {

                Console.Write(ex.Message);

            }

}

The exception message:

[Acr.UserDialogs] In android, you must call UserDialogs.Init(Activity) from your first activity OR UserDialogs.Init(App) from your custom application OR provide a factory function to get the current top activity via UserDialogs.Init(() => supply top activi...

I don't have a clue why the dialog service is not working.
I already tried differenct positions for calling the UserDialog init, and already the different init call UserDialogs.Init(() => (Activity)Forms.Context).
But still - the dialog crashes.

I'm testing everything via Xamarin Live Player.
Any help would be much appreciated!

Edit: I found this issue on Github (Issue 449, i can't post links in this forum because i'm to new ...) Sounds like Xamarin Live Player can't handle this package, so what can i do? :neutral:

Greetings!
Niklas


Viewing all articles
Browse latest Browse all 204402

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>