Пример #1
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            AppCenter.Start("b17f9c9d-e90c-488f-8c4b-92ef3e305c0d", typeof(Analytics), typeof(Distribute));


            WifiManager wifiMgr = (WifiManager)ApplicationContext.GetSystemService(Context.WifiService);

            castLock = wifiMgr.CreateMulticastLock("TacControl-udp");
            castLock.SetReferenceCounted(true);
            castLock.Acquire();


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

            base.OnCreate(savedInstanceState);

            Xamarin.Essentials.Platform.Init(this, savedInstanceState);
            global::Xamarin.Forms.Forms.Init(this, savedInstanceState);

            Android.Views.Window window = Window;
            window.AddFlags(WindowManagerFlags.KeepScreenOn);
            window.AddFlags(WindowManagerFlags.Fullscreen);

            LoadApplication(new App((action) =>
            {
                TaskCompletionSource <object> tcs = new TaskCompletionSource <object>();
                bool isMain = MainThread.IsMainThread;

                RunOnUiThread(() =>
                {
                    try
                    {
                        action();
                        tcs.SetResult(null);
                    }
                    catch (Exception ex)
                    {
                        tcs.SetException(ex);
                    }
                });

                return(tcs.Task);
            }));
        }
Пример #2
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            AppCenter.Start("b17f9c9d-e90c-488f-8c4b-92ef3e305c0d", typeof(Analytics), typeof(Distribute));

            var versionInfo = Application.Context.ApplicationContext?.PackageManager?.GetPackageInfo(Application.Context.ApplicationContext.PackageName, 0);

            //var username = System.Security.Principal.WindowsIdentity.GetCurrent();

            SentryXamarin.Init(o =>
            {
                o.AddXamarinFormsIntegration();
                o.Dsn         = "https://[email protected]/5390642";
                o.Release     = $"TacControl@{versionInfo?.VersionName}:{versionInfo?.LongVersionCode}";
                o.Environment = //username == "Dedmen-PC\\dedmen" ? "Dev" :
                                "Alpha";
            });


            WifiManager wifiMgr = (WifiManager)ApplicationContext.GetSystemService(Context.WifiService);

            wifiLock = wifiMgr.CreateWifiLock(WifiMode.Full, "TacControl-udp");
            wifiLock.SetReferenceCounted(true);
            wifiLock.Acquire();
            castLock = wifiMgr.CreateMulticastLock("TacControl-udp");
            castLock.SetReferenceCounted(true);
            castLock.Acquire();


            ConnectivityManager conMgr = (ConnectivityManager)ApplicationContext.GetSystemService(Context.ConnectivityService);
            var stuff   = conMgr.GetAllNetworks();
            var wifiNet = stuff.FirstOrDefault(x => conMgr.GetNetworkInfo(x).Type == ConnectivityType.Wifi);

            if (wifiNet != null)
            {
                var res  = conMgr.BindProcessToNetwork(wifiNet);
                var info = conMgr.GetNetworkInfo(wifiNet);

                var connInfo = wifiMgr.ConnectionInfo;
            }


            //Networking.ConnectionInfo

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

            base.OnCreate(savedInstanceState);

            Xamarin.Essentials.Platform.Init(this, savedInstanceState);
            global::Xamarin.Forms.Forms.Init(this, savedInstanceState);

            Android.Views.Window window = Window;
            window.AddFlags(WindowManagerFlags.KeepScreenOn);
            window.AddFlags(WindowManagerFlags.Fullscreen);

            LoadApplication(new App((action) =>
            {
                TaskCompletionSource <object> tcs = new TaskCompletionSource <object>();
                bool isMain = MainThread.IsMainThread;

                RunOnUiThread(() =>
                {
                    try
                    {
                        action();
                        tcs.SetResult(null);
                    }
                    catch (Exception ex)
                    {
                        tcs.SetException(ex);
                    }
                });

                return(tcs.Task);
            }));
        }