void UpdateReceivedData(byte[] data)
        {
            try
            {
                ConnectivityManager ConnectivityManager = (ConnectivityManager)Application.Context.GetSystemService(Context.ConnectivityService);
                NetworkInfo         connection          = ConnectivityManager.ActiveNetworkInfo;
                if (connection != null && connection.IsConnected && CrossConnectivity.Current.IsConnected)
                {
                    var message = HexDump.DumpHexString(data) + "\n\n";
                    dumpTextView.Append(message);
                    scrollView.SmoothScrollTo(0, dumpTextView.Bottom);
                }
                else
                {
                    if (wake.IsHeld && wifilock.IsHeld)
                    {
                        wake.Release();     //libera wakeLock
                        wifilock.Release(); //libera wifiLock
                    }
                    activateSleep = false;
                    PowerManager pwm = (PowerManager)GetSystemService(Context.PowerService);
                    WakeLock     wkl = pwm.NewWakeLock(WakeLockFlags.Full | WakeLockFlags.AcquireCausesWakeup | WakeLockFlags.OnAfterRelease, "wakeup device");
                    wkl.Acquire();
                    wkl.Release();

                    Finish();
                    intent = PackageManager.GetLaunchIntentForPackage("com.flexolumens.MonitorInteligente");
                    StartActivity(intent);
                    //OnDestroy();
                }

                if (activateSleep == true && (connection != null && connection.IsConnected) && CrossConnectivity.Current.IsConnected)
                {
                    wake.Acquire();
                    wifilock.Acquire();
                    activateSleep = false;
                    intento       = PackageManager.GetLaunchIntentForPackage("com.ssaurel.lockdevice");
                    StartActivity(intento);
                    //if (!wifi.IsWifiEnabled)
                    //{
                    //wifi.SetWifiEnabled(true);
                    //}
                }
            }
            catch (Exception ex)
            {
                Toast.MakeText(this, ex.Message, ToastLength.Long).Show();
            }
        }
Пример #2
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;
            }
        }
Пример #3
0
 protected override void OnDestroy()
 {
     wifilock.Release();
     base.OnDestroy();
 }