Пример #1
0
        protected override void OnCreate(Bundle bundle)
        {
            TabLayoutResource = Resource.Layout.Tabbar;
            ToolbarResource   = Resource.Layout.Toolbar;

            base.OnCreate(bundle);

            AutoUpdate.Init(this, "com.companyname.Samples.fileProvider");
            global::Xamarin.Forms.Forms.Init(this, bundle);

            LoadApplication(new App());
        }
Пример #2
0
        protected override void OnCreate(Bundle bundle)
        {
            TabLayoutResource = Resource.Layout.Tabbar;
            ToolbarResource   = Resource.Layout.Toolbar;

            base.Window.RequestFeature(WindowFeatures.ActionBar);
            base.OnCreate(bundle);

            mContext = this;
            Instance = this;

            try
            {
                var width   = Resources.DisplayMetrics.WidthPixels;
                var height  = Resources.DisplayMetrics.HeightPixels;
                var density = Resources.DisplayMetrics.Density; //屏幕密度
                App.ScreenWidth  = width / density;             //屏幕宽度
                App.ScreenHeight = height / density;            //屏幕高度
            }
            catch (System.Exception) { }

            //返回此活动是否为任务的根
            if (!IsTaskRoot)
            {
                Finish();
                return;
            }

            PowerManager pm = (PowerManager)GetSystemService(Context.PowerService);

            isPause = pm.IsScreenOn;
            if (handler == null)
            {
                handler = new Handler();
            }


            //注册广播,屏幕点亮状态监听,用于单独控制音乐播放
            if (screenStateReceiver == null)
            {
                screenStateReceiver = new ScreenStateReceiver();
                var intentFilter = new IntentFilter();
                intentFilter.AddAction("_ACTION_SCREEN_OFF"); //熄屏
                intentFilter.AddAction("_ACTION_SCREEN_ON");  //点亮
                intentFilter.AddAction("_ACTION_BACKGROUND"); //后台
                intentFilter.AddAction("_ACTION_FOREGROUND"); //前台
                RegisterReceiver(screenStateReceiver, intentFilter);
            }


            Window.AddFlags(WindowManagerFlags.KeepScreenOn);
            if (Build.VERSION.SdkInt >= BuildVersionCodes.Lollipop)
            {
                Window.ClearFlags(WindowManagerFlags.TranslucentStatus);
                Window.AddFlags(WindowManagerFlags.TranslucentNavigation);
                TranslucentStatubar.Immersive(Window);
                Window.AddFlags(WindowManagerFlags.DrawsSystemBarBackgrounds);
                Window.ClearFlags(WindowManagerFlags.Fullscreen);
            }

            //在andrioid m之后,必须在运行时请求权限
            GetPersimmions();

            //图片裁切
            BitImageEditor.Droid.Platform.Init(this, bundle);

            //初始 Popup
            Popup.Init(this);

            //版本更新配置
            AutoUpdate.Init(this, "com.dcms.clientv3.fileprovider");

            //初始 Xamarin.Forms 实验性标志
            Forms.SetFlags("Shell_Experimental",
                           "SwipeView_Experimental",
                           "CarouselView_Experimental",
                           "RadioButton_Experimental",
                           "IndicatorView_Experimental",
                           "Expander_Experimental",
                           "Visual_Experimental",
                           "CollectionView_Experimental",
                           "FastRenderers_Experimental");

            #region //初始 FFImageLoading

            CachedImageRenderer.Init(true);
            CachedImageRenderer.InitImageViewHandler();
            ImageCircleRenderer.Init();
            var config = new FFImageLoading.Config.Configuration()
            {
                VerboseLogging                 = false,
                VerbosePerformanceLogging      = false,
                VerboseMemoryCacheLogging      = false,
                VerboseLoadingCancelledLogging = false,
            };
            ImageService.Instance.Initialize(config);

            #endregion

            Forms.Init(this, bundle);

            //初始 对话框组件
            UserDialogs.Init(this);

            //初始 ZXing
            ZXingPlatform.Platform.Init();

            LoadApplication(new App(new AndroidInitializer()));
        }