2017-07-15 68 views
2

我的应用程序工作正常。突然之间,我意识到当我尝试登录并使用Facebook注销时出现此错误。在我的应用程序中,当我通过Faceboook登录时,它从Facebook登录页面验证通过成功页面页面。类型参数名称:类型不是从java类型派生的。 - Xamarin android

在成功页面,用户点击继续,当我点击继续,我得到的错误

类型参数名:类型不从Java类的。 。

应用崩溃并重新启动后,我看到,用户在 被记录当我退出过,也得到了同样的错误

类型参数名:类型不是从派生java类型。

该应用程序崩溃,但用户注销。我搜查了其他相关的问题,但没有人能帮助我。

这是什么造成的?

public class successPage : Activity 

    { 
     Button button; 
     TextView textViewActivity; 
     FirebaseAuth mAuth; 

     protected override void OnCreate(Bundle savedInstanceState) 
     { 
      base.OnCreate(savedInstanceState); 


      SetContentView(Resource.Layout.successPage); 

      button = (Button)FindViewById(Resource.Id.button); 

      textViewActivity = (TextView)FindViewById(Resource.Id.textView); 

      mAuth = FirebaseAuth.Instance; 



      button.Click += onBtnClick; 

      //textViewActivity.Text = user.DisplayName; 



      // Create your application here 
     } 

     private void onBtnClick(object sender, EventArgs e) 
     { 
      Intent success = new Intent(this, (typeof(EventNews))); 
      StartActivity(success); 
     } 
    } 

Intent success = new Intent(this, (typeof(EventNews))); 

EventNews

public class EventNews : BaseActivity, IValueEventListener 
    { 

     protected override void OnCreate(Bundle savedInstanceState) 
     { 
      base.OnCreate(savedInstanceState); 


      FrameLayout content = (FrameLayout)FindViewById(Resource.Id.content_frame); 
      LayoutInflater.Inflate(Resource.Layout.EventNews, content); 



      //initializing firebase 
      user = FirebaseAuth.Instance.CurrentUser; 


      toolbarMain = (Android.Support.V7.Widget.Toolbar)FindViewById<Android.Support.V7.Widget.Toolbar>(Resource.Id.toolBar); 

      SetSupportActionBar(toolbarMain); 

      TextView toolbarName = (TextView)FindViewById(Resource.Id.counter_text); 

     } 

     } 

     public override bool OnCreateOptionsMenu(IMenu menu) 
     { 

      MenuInflater.Inflate(Resource.Menu.top_menus, menu); 

      var item = menu.FindItem(Resource.Id.search); 

      var searchview = (Android.Support.V7.Widget.SearchView)MenuItemCompat.GetActionView(item); 

      searchview.QueryTextChange += (s, e) => 
      { 

       adapter.Filter.InvokeFilter(e.NewText); 



      }; 

      searchview.QueryTextSubmit += (s, e) => 

      { 

       Toast.MakeText(this, "Searched for: " + e.Query, ToastLength.Short).Show(); 
       e.Handled = true; 
      }; 

      MenuItemCompat.SetOnActionExpandListener(item, new SearchViewExpandListener(adapter)); 




      return base.OnCreateOptionsMenu(menu); 

     } 

     private void Adapter_ItemClick(object sender, int position) 
     { 


     } 

     private class SearchViewExpandListener : Java.Lang.Object, MenuItemCompat.IOnActionExpandListener 
     { 
      private readonly IFilterable _adapter; 

      public SearchViewExpandListener(IFilterable adapter) 
      { 
       _adapter = adapter; 

      } 
      public bool OnMenuItemActionCollapse(IMenuItem item) 
      { 
       _adapter.Filter.InvokeFilter(""); 
       return true; 
      } 

      public bool OnMenuItemActionExpand(IMenuItem item) 
      { 
       return true; 
      } 
     } 

     public void OnCancelled(DatabaseError error) 
     { 
      throw new NotImplementedException(); 
     } 

     public void OnDataChange(DataSnapshot snapshot) 
     { 

      eventNews.Clear(); 
      var items = snapshot.Children.ToEnumerable<DataSnapshot>(); 

      HashMap map; 
      foreach (DataSnapshot item in items) 
      { 
       map = (HashMap)item.Value; 

       eventNews.Add(new EventNews(item.Key.ToString(),map.Get("Name")?.ToString(), map.Get("Achievement")?.ToString(),map.Get("History")?.ToString(),map.Get("Quote")?.ToString(), map.Get("Ref").ToString())); 
      } 

      //list items on listview 
      rv.SetLayoutManager(new LinearLayoutManager(this)); 
      rv.SetItemAnimator(new DefaultItemAnimator()); 
      rv.SetAdapter(adapter); 
      mDialog.Dismiss(); 


     } 
    } 

误差点,这条线栈跟踪

at Java.Lang.Class.FromType (System.Type type) [0x00012] in <d855bac285f44dda8a0d8510b679b1e2>:0 
    at Android.Content.Intent..ctor (Android.Content.Context packageContext, System.Type type) [0x00000] in <d855bac285f44dda8a0d8510b679b1e2>:0 
    at peaceApp.Droid.successPage.onBtnClick (System.Object sender, System.EventArgs e) [0x00002] in /Users/emmnock/Documents/Projects/peaceApp/Droid/successPage.cs:76 
    at Android.Views.View+IOnClickListenerImplementor.OnClick (Android.Views.View v) [0x00011] in <d855bac285f44dda8a0d8510b679b1e2>:0 
    at Android.Views.View+IOnClickListenerInvoker.n_OnClick_Landroid_view_View_ (System.IntPtr jnienv, System.IntPtr native__this, System.IntPtr native_v) [0x0000f] in <d855bac285f44dda8a0d8510b679b1e2>:0 
    at (wrapper dynamic-method) System.Object:579ed970-959a-4157-8d2c-b00f36f55fa7 (intptr,intptr,intptr) 
+0

这条线上的错误点'Intent success = new Intent(this,(typeof(EventNews)));' – Switz

+0

你可以添加'EventNews'是什么吗? –

+2

第二个参数需要一个类,我认为,而不是一个类型。 –

回答

0

如果选中这个文件Passing Data Between Activities

那么你可能已经注意到这条线:

添加一个名为活性2到项目第二活动类。 此类必须继承自Android.App.Activity

所以问题出在typeof(EventNews)。出于某种原因,正在传递的类型不是您的活动类型。这可能是因为如果您有两个具有相同名称但名称空间不同的类。

+0

我真的不知道这个。因为我的应用程序中有大约4个其他活动继承了BaseActivity,并且我能够在活动之间传递数据。基本活动从AppCompatActivity继承。那是我设置我的导航器抽屉和工具栏的地方。 – Switz