Forum Xamarin.Forms

Problem with the resume of my app.

LorenzoVerbruggheLorenzoVerbrugghe FRMember
edited May 2016 in Xamarin.Forms

I post here because I have a bug with my Xamarin.Forms application. I think I have some problems because of the onResume() portion of code with the Android part. (In the MainActivity.cs file)

When I leave my app with the back button, or when I open it from the notification center (because my app sometimes send notifications),
the application opens correctly but my Google Map is not properly loaded and the color on my slider (which should be a color gradient) becomes grey.
With this problem, my map doesn't properly load, and the geolocator fail to focus the map on my position.
The problem is not present when I leave the app from the "Home" button. I guess that it comes from the onResume() because of the android activity lifecycle. I'll paste the MainActivity.cs file if someone could help me with this It would help me a lot.
I don't know what to add in the onResume() portion of code to make it load properly.
Thanks for helping !

    protected override void OnCreate (Bundle bundle)
        base.OnCreate (bundle);

        App.androidActivity = this;

        // Facebook initialisation

        // Creation of facebook callback manager
        callbackManager = CallbackManagerFactory.Create();

        // Definition of callbacks for Xamarin :O
        LoginManager.Instance.RegisterCallback (callbackManager, this);

        // Preparing the login manager actions
        MessagingCenter.Subscribe<object> (this, "LoginWithReadPermissionsInFacebook", (sender) => {
            LoginManager.Instance.LogInWithReadPermissions(this, new List<string>{"public_profile","user_friends"});

        MessagingCenter.Subscribe<object> (this, "LogOutFromFacebook", (sender) => {

        // Init of Xlabs :)
        DependencyService.Register<Geolocator> ();

        // Init of Xamarin
        global::Xamarin.Forms.Forms.Init (this, bundle);
        Xamarin.FormsMaps.Init (this, bundle);
        Forms.SetTitleBarVisibility (AndroidTitleBarVisibility.Never);

        LoadApplication (new App());

    public override void OnBackPressed()
        if(OutMySphere.App.IsLoggedIn() && AccessToken.CurrentAccessToken != null && Profile.CurrentProfile != null)


    protected override void OnResume()
        base.OnResume ();

    public void OnCancel()
        MessagingCenter.Send<object> (this, "AccessDenied");

    public void OnError(FacebookException error)
        MessagingCenter.Send<object> (this, "AccessDenied");

    public void OnSuccess(Java.Lang.Object result)
        MessagingCenter.Send<object> (this, "FacebookLoginSuccess");

    protected override void OnActivityResult(int requestCode, Result resultCode, Intent data)
        base.OnActivityResult (requestCode, resultCode, data);
        callbackManager.OnActivityResult (requestCode, (int)resultCode, data);
Sign In or Register to comment.