Just as for iOS, the bootstrapper for Android is a simple wrapper for the common bootstrapper defined in the .NET Standard library, but with the addition of an Init method that is called at startup:
- In the root of the Android project, create a new class called Bootstrapper.cs.
- Add the following code to it:
public class Bootstrapper : DoToo.Bootstrapper
{
public static void Init()
{
var instance = new Bootstrapper();
}
}
We then need to call this Init method. A good place to do this is right before the LoadApplication call in OnCreate:
- Open up MainActivity.cs.
- Locate the OnCreate method and add the code in bold from the following code block:
protected override void OnCreate(Bundle savedInstanceState)
{
TabLayoutResource = Resource.Layout.Tabbar;
ToolbarResource = Resource.Layout.Toolbar;
base.OnCreate(savedInstanceState);
Xamarin.Essentials.Platform.Init(this, savedInstanceState);
global::Xamarin.Forms.Forms.Init(this, savedInstanceState);
Bootstrapper.Init();
LoadApplication(new App());
}