当我按下返回按钮时,应用崩溃

时间:2019-06-26 11:00:13

标签: xamarin xamarin.forms xamarin.android

在我的Xamarin.Forms应用中,当我按“后退”按钮时,应用崩溃。

MainActivity.cs 中,我已按如下所示进行了覆盖

public override void OnBackPressed()
        {            
            if (PersistanceHelper.Instance.Token == "")
            {
                Finish();
            }
            else
            {
                PersistanceHelper.Instance.OparationDatetime = DateTime.Now.ToString();
                PersistanceHelper.Instance.Token = "";
                base.OnBackPressed();
            }
}

更新

这就是我得到的错误日志

System.ObjectDisposedException: Cannot access a disposed object.
Object name: 'Xamarin.Forms.Platform.Android.AppCompat.MasterDetailPageRenderer'.

06-27 08:23:06.701 E/mono    (18040): 
06-27 08:23:06.701 E/mono    (18040): Unhandled Exception:
06-27 08:23:06.701 E/mono    (18040): System.ObjectDisposedException: Cannot access a disposed object.
06-27 08:23:06.701 E/mono    (18040): Object name: 'Xamarin.Forms.Platform.Android.AppCompat.MasterDetailPageRenderer'.
06-27 08:23:06.701 E/mono    (18040):   at (wrapper dynamic-method) Android.Runtime.DynamicMethodNameCounter.19(intptr,intptr)
06-27 08:23:06.701 E/mono    (18040):   at (wrapper native-to-managed) Android.Runtime.DynamicMethodNameCounter.19(intptr,intptr)
06-27 08:23:06.701 E/mono-rt (18040): [ERROR] FATAL UNHANDLED EXCEPTION: System.ObjectDisposedException: Cannot access a disposed object.
06-27 08:23:06.701 E/mono-rt (18040): Object name: 'Xamarin.Forms.Platform.Android.AppCompat.MasterDetailPageRenderer'.
06-27 08:23:06.701 E/mono-rt (18040):   at (wrapper dynamic-method) Android.Runtime.DynamicMethodNameCounter.19(intptr,intptr)
06-27 08:23:06.701 E/mono-rt (18040):   at (wrapper native-to-managed) Android.Runtime.DynamicMethodNameCounter.19(intptr,intptr)

0 个答案:

没有答案