我正在尝试在我的Xamarin.Android项目中启动并运行通知。出于某种原因,当我在手机上运行应用程序时,它会崩溃并返回null。我现在已经处理了一段时间了,但我似乎不明白问题是什么。
我已经尝试在beggining中保存变量的上下文,并在需要时稍后调用它,但它也不起作用。
这是我的OnCreate方法,包括导致错误的行:
protected override void OnCreate(Bundle bundle)
{
if (Intent.Extras != null)
{
foreach (var key in Intent.Extras.KeySet())
{
var value = Intent.Extras.GetString(key);
Log.Debug(TAG, "Key: {0} Value: {1}", key, value);
}
}
TabLayoutResource = Resource.Layout.Tabbar;
ToolbarResource = Resource.Layout.Toolbar;
base.OnCreate(bundle);
if (!Resolver.IsSet) SetIoc();
LayoutInflater inflater;
Context context = this.BaseContext;
inflater = LayoutInflater.FromContext(context);
View dialogView = inflater.Inflate(Resource.Layout.Main, null);
SetContentView(Resource.Layout.Main);
msgText = dialogView.FindViewById<TextView>(Resource.Id.msgText);
IsPlayServicesAvailable();
Xamarin.FormsMaps.Init(this, bundle);
Xamarin.Forms.Forms.Init(this, bundle);
FormsControls.Droid.Main.Init(this); //this one is crashing
LoadApplication(new App());
FirebaseApp app = FirebaseApp.InitializeApp(this);
ConfigureFireBase();
}