Xamarin Live Player does not start OnCreate in Android project, using the VS default project

喜夏-厌秋 提交于 2019-12-13 02:17:23

问题


All components are up to date, so is Visual Studio.

I created a new project:

When I start it with the emulators, everything works fine. When I start it with the live player and my Sony Xperia Compact 5, it connects nicely, but the Android code in MainActivity is not used.

Only one modification I made, I write to the trace. The breakpoint is also never hit, unless I use an emulator instead.

using System;

using Android.App;
using Android.Content.PM;
using Android.Runtime;
using Android.Views;
using Android.Widget;
using Android.OS;


namespace App5KittyOp.Droid
{
    [Activity(Label = "App5KittyOp", Icon = "@drawable/icon", Theme = "@style/MainTheme", MainLauncher = true, ConfigurationChanges = ConfigChanges.ScreenSize | ConfigChanges.Orientation)]
    public class MainActivity : global::Xamarin.Forms.Platform.Android.FormsAppCompatActivity
    {
        protected override void OnCreate(Bundle bundle)
        {
            System.Diagnostics.Debug.WriteLine("In OnCreate");

            TabLayoutResource = Resource.Layout.Tabbar;
            ToolbarResource = Resource.Layout.Toolbar;

            base.OnCreate(bundle);

            global::Xamarin.Forms.Forms.Init(this, bundle);
            LoadApplication(new App());
        }
    }
}

The dependency injection which I added from the beginners tutorial, also worked fine. So, the code in the Android project is used, except the MainActivity.

I have been programming ASP.net since the 90s but I am new to xamarin. Any help would be apreciated.

来源:https://stackoverflow.com/questions/49885017/xamarin-live-player-does-not-start-oncreate-in-android-project-using-the-vs-def

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!