我正在尝试将我现有的 Xamarin.Forms 应用程序与 MvvmCross.Forms 放在一起 . 不幸的是我无法进行初始化 .
MainActivity.cs
[Activity(MainLauncher = true, Label = "Main Activity")]
public class MainActivity : FormsApplicationActivity
{
protected override void OnCreate(Bundle bundle)
{
base.OnCreate(bundle);
Forms.Init(this, bundle);
var app = new MvxFormsApp();
LoadApplication(app);
var presenter = (MvxFormsDroidPagePresenter) Mvx.Resolve<IMvxViewPresenter>(); // Exception
presenter.MvxFormsApp = app;
Mvx.Resolve<IMvxAppStart>().Start();
}
}
Setup.cs
public class Setup : MvxAndroidSetup
{
public Setup(Context applicationContext) : base(applicationContext)
{
}
protected override IMvxApplication CreateApp()
{
return new App();
}
protected override IMvxAndroidViewPresenter CreateViewPresenter()
{
var presenter = new MvxFormsDroidPagePresenter();
Mvx.RegisterSingleton<IMvxViewPresenter>(presenter);
return presenter;
}
}
我想问题是 Setup is not called ,甚至不是构造函数 . 我对吗?代码有什么问题?
1 回答
引导在启动屏幕中完成 .
您必须从
MainActivity
中删除MainLauncher = true
并添加如下的启动画面:如果您需要一个有效的示例,请参阅我们的示例应用:https://github.com/xabre/xamarin-bluetooth-le/tree/master/Source/BLE.Client