使用其他应用后恢复正常

时间:2015-08-10 19:40:14

标签: android xamarin mono

使用其他应用程序(如相机)后,应用程序崩溃onResume。下面是静态构造函数:

 public static DashboardFragment newInstance(int ZoneIndex, bool isTablet, DashboardActivity Activity)
 {
     Bundle Args = new Bundle();
     Args.PutInt(Constants.Values.ZONE_INDEX, ZoneIndex);
     Args.PutBoolean(Constants.Values.TABLET, isTablet);
     DashboardFragment DashboardFragment = new DashboardFragment();
     DashboardFragment.Arguments = Args;
     _Activity = Activity;
     return DashboardFragment;
 }

Unable to find the default constructor on type MyProject.Adapters.ViewPagerFragment. **Please provide the missing constructor**. ---> Java.Interop.JavaLocationException: Exception of type 'Java.Interop.JavaLocationException' was thrown.Java.Lang.Error: Exception of type 'Java.Lang.Error' was thrown. --- End of managed exception stack trace ---java.lang.Error: Java callstack: at mono.android.TypeManager.n_activate(Native Method) at mono.android.TypeManager.Activate(TypeManager.java:7)

1 个答案:

答案 0 :(得分:-1)

不确定崩溃是什么,但java中健康的newInstance()看起来像这样:

public static MyFragment newInstance(String a, String b) {
    MyFragment fragment = new MyFragment();
    Bundle args = new Bundle();
    args.putString(ARG_A, a);
    args.putString(ARG_B, b);
    fragment.setArguments(args);
    return fragment;
}

这条线也让我担心: _Activity = Activity;您应该让Android生命周期方法处理它。 https://developer.android.com/guide/components/fragments.html#Lifecycle

但话说回来,我对Xamarin没有经验。