Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

SetPage(Xamarin.Forms.Page)' is obsolete error - Android

I have created a universal application with Xamarin Forms

I get the warning

Xamarin.Forms.Platform.Android.FormsApplicationActivity.SetPage(Xamarin.Forms.Page)' is obsolete

Has anyone come across this?

The code is shown below

public class MainActivity : AndroidActivity
{
    protected override void OnCreate (Bundle bundle)
    {
        base.OnCreate (bundle);

        Xamarin.Forms.Forms.Init (this, bundle);    
        SetPage (App.GetMainPage ());
    }
}

Paul

like image 948
Paul Avatar asked Mar 17 '23 11:03

Paul


1 Answers

Forms 1.3.1 supports a new Application class that has a MainPage property, which allows you to set the App start page in a single location (rather than once per platform).

public class App : Application // superclass new in 1.3
{
    public App ()
    {
        // The root page of your application
        MainPage = new ContentPage {...}; // property new in 1.3
    }

A Migration Guide is available which outlines all of the changes you will need to make in your app for the new API.

like image 126
Jason Avatar answered Apr 02 '23 07:04

Jason