Configure Android
Install
- Install WhiteLabel via NuGet or such as submodule.
Setup
Configure project
Remove
MainActivity.cs
.Create
MainApplication
in the root folder and paste the following code:
[Application]
public class MainApplication : MainApplicationBase
{
protected MainApplication(IntPtr handle, JniHandleOwnership transfer)
: base(handle, transfer)
{
}
protected override IBootstrapper CreateBootstrapper()
{
return new CustomBootstrapper();
}
}
- Create
SplashActivity
:
[Activity(
MainLauncher = true,
NoHistory = true)]
public class SplashActivity : AppCompatActivity
{
protected override void OnCreate(Bundle savedInstanceState)
{
base.OnCreate(savedInstanceState);
// Entry point
Dependencies.PageNavigationService
.For<MainPageViewModel>()
.Navigate();
Finish();
}
}
Configure dependencies
Create custom Bootsrapper:
public class CustomBootstrapper : DroidBootstrapperBase
{
protected override void ConfigureIoc(IContainerBuilder builder)
{
builder.Singleton<JsonSerializer, IJsonSerializer>(); // for saving states
// you can register any dependencies here
}
protected override IList<Assembly> SelectAssemblies()
{
// for auto-registering ViewModels by Activities
return base.SelectAssemblies()
.AddItem(GetType().Assembly);
}
}