我的应用程序运行正常。突然间,当我尝试登录并使用Facebook注销时,我意识到我收到了此错误。在我的应用程序中,当我通过Faceboook登录时,它从Facebook登录页面到成功页面页面进行身份验证。
在成功页面上,用户点击继续,当我点击继续时,我收到错误
type参数名称:Type不是从java类型派生的。
在我看到用户已登录后,应用程序崩溃并重新启动。 当我注销时,它也会出现同样的错误
type参数名称:Type不是从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 :(得分:0)
如果您已查看此文档Passing Data Between Activities
然后你可能已经注意到这一行:
将第二个名为Activity2的活动类添加到项目中。 此类必须继承自Android.App.Activity 。
问题出在typeof(EventNews)
。由于某种原因,传递的类型不是您的活动类型。如果您有两个具有相同名称但位于不同名称空间的类,则可能是这样。