コード例 #1
0
        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);
            StrictMode.ThreadPolicy policy = new StrictMode.ThreadPolicy.Builder().PermitAll().Build();
            StrictMode.SetThreadPolicy(policy);

            var wifi = (WifiManager)GetSystemService(WifiService);
            var ConnectivityManager = (ConnectivityManager)GetSystemService(ConnectivityService);

            wifilock = wifi.CreateWifiLock(WifiMode.FullHighPerf, "WifiLock");
            wifilock.Acquire();

            game = new Game1(
                CreateUdpService(wifi, ConnectivityManager)
                , RuningOnAndroid: true
                );

            if (Build.VERSION.SdkInt >= BuildVersionCodes.O)
            {
                Vibrator vibrator = (Vibrator)GetSystemService(VibratorService);
                Game1.AndroidVibrate = f => vibrator.Vibrate(VibrationEffect.CreateOneShot(f, VibrationEffect.DefaultAmplitude));
            }
            else
            {
                //TODO:
            }

            SetViewFullScreen();

            //PowerManager pm = (PowerManager)GetSystemService(PowerService);
            //this.mWakeLock = pm.NewWakeLock(WakeLockFlags.ScreenDim, "My Tag");
            //this.mWakeLock.Acquire();
            game.Run();
        }
コード例 #2
0
        protected override void OnCreate(Bundle bundle)
        {
            Log.Info(TAG, "OnCreate");

            base.OnCreate(bundle);

            SetContentView(Resource.Layout.serial_console);

            usbManager    = GetSystemService(Context.UsbService) as UsbManager;
            titleTextView = FindViewById <TextView>(Resource.Id.demoTitle);
            dumpTextView  = FindViewById <TextView>(Resource.Id.consoleText);
            scrollView    = FindViewById <ScrollView>(Resource.Id.demoScroller);
            wifi          = (WifiManager)GetSystemService(WifiService);
            wifilock      = wifi.CreateWifiLock(WifiMode.FullHighPerf, "wifi keep On");
            pm            = (PowerManager)GetSystemService(Context.PowerService);       //new line
            wake          = pm.NewWakeLock(WakeLockFlags.Partial, "stay awake gently"); //new line
            activateSleep = true;                                                       //new line
        }
コード例 #3
0
        /// <summary>
        /// Called as part of the activity lifecycle when an activity is going into
        /// the background, but has not (yet) been killed.
        /// </summary>
        public override void OnPause()
        {
            base.OnPause();

            WifiLock.Release();
            WakeLock.Release();

            PlayerView.HideController();

            if (VideoPlayer != null)
            {
                VideoPlayer.PlayWhenReady = false;

                try
                {
                    LastUrl      = Data.FromJson <string>();
                    LastPosition = VideoPlayer.CurrentPosition;
                    var duration = VideoPlayer.Duration;

                    //
                    // Times our in milliseconds.
                    //
                    if (LastPosition > (duration - 300000) || LastPosition < 60000)
                    {
                        LastUrl      = null;
                        LastPosition = null;
                    }

                    AutoResumePosition = VideoPlayer.CurrentPosition;
                }
                catch
                {
                    LastUrl      = null;
                    LastPosition = null;
                }

                VideoPlayer       = null;
                PlayerView.Player = null;
            }
        }
コード例 #4
0
        /// <summary>
        /// Called when the fragment is visible to the user and actively running.
        /// </summary>
        public override void OnResume()
        {
            base.OnResume();

            WakeLock.Acquire();
            WifiLock.Acquire();

            var url = Data.FromJson <string>();

            if (AutoResumePosition.HasValue)
            {
                PlayVideo(url, AutoResumePosition);
            }
            else if (LastUrl == url && LastPosition.HasValue)
            {
                ShowResumeDialog();
            }
            else
            {
                PlayVideo(url, null);
            }
        }