private void OnTunnelStated(){
			//ShowConnected();
			this.StartService(intent);
			PowerManager mgr = (PowerManager)GetSystemService(Android.Content.Context.PowerService);
			wakeLock = mgr.NewWakeLock( WakeLockFlags.ScreenDim, "MyWakeLock");
			wakeLock.Acquire();
		}
Esempio n. 2
0
        /// <summary>
        /// Creates a WakeHolder object
        /// </summary>
        public WakeHolder()
        {
            Context      context = Android.App.Application.Context;
            PowerManager pm      = (PowerManager)context.GetSystemService(Context.PowerService);

            wakeLock = pm.NewWakeLock(WakeLockFlags.Partial, "Background Service Provided WakeLock");
            wakeLock.Acquire();
        }
        private void OnTunnelStated()
        {
            //ShowConnected();
            this.StartService(intent);
            PowerManager mgr = (PowerManager)GetSystemService(Android.Content.Context.PowerService);

            wakeLock = mgr.NewWakeLock(WakeLockFlags.ScreenDim, "MyWakeLock");
            wakeLock.Acquire();
        }
Esempio n. 4
0
		public static void Acquire(Context ctx) {
			if (wakeLock != null) wakeLock.Release();

			PowerManager pm = (PowerManager) ctx.GetSystemService(Context.PowerService);
			wakeLock = pm.NewWakeLock(WakeLockFlags.Full |
				WakeLockFlags.AcquireCausesWakeup |
				WakeLockFlags.OnAfterRelease, TAG);
			wakeLock.Acquire();
		}
            public static void RunIntentInService(Context context, Intent intent)
            {
                lock (LOCK)
                {
                    if (sWakeLock == null)
                    {
                        // This is called from BroadcastReceiver, there is no init.
                        var pm = Android.OS.PowerManager.FromContext(context);
                        sWakeLock = pm.NewWakeLock(Android.OS.WakeLockFlags.Partial, "My WakeLock Tag");
                    }
                }

                sWakeLock.Acquire();
                intent.SetClass(context, typeof(PNIntentService));
                context.StartService(intent);
            }
Esempio n. 6
0
        /// <summary>
        /// Activates or desactivates the auto sleep mode. True to activate it (default), False to deactivate it.
        /// Use with caution: if you deactivated auto sleep you will need to reactivate it.
        /// DoWithoutSleep and DoWithoutSleepAsync methods are preferred since they automatically resume auto sleep.
        /// </summary>
        /// <param name="activateAutoSleepMode">If set to <c>true</c> activate auto sleep mode.</param>
        public override void ActivateAutoSleepMode(bool activateAutoSleepMode)
        {
            var powerMgr = (Android.OS.PowerManager)Android.App.Application.Context.GetSystemService(Context.PowerService);

            if (_wakeLock == null)
            {
                _wakeLock = powerMgr.NewWakeLock(Android.OS.WakeLockFlags.Partial, typeof(SleepMode).FullName);
            }

            if (activateAutoSleepMode)
            {
                _wakeLock.Release();
            }
            else
            {
                _wakeLock.Acquire();
            }
        }
        /// <summary>
        /// Activates or desactivates the auto sleep mode. True to activate it (default), False to deactivate it.
        /// Use with caution: if you deactivated auto sleep you will need to reactivate it.
        /// DoWithoutSleep and DoWithoutSleepAsync methods are preferred since they automatically resume auto sleep.
        /// </summary>
        /// <param name="activateAutoSleepMode">If set to <c>true</c> activate auto sleep mode.</param>
        public override void ActivateAutoSleepMode(bool activateAutoSleepMode)
        {
            var powerMgr = (Android.OS.PowerManager) Android.App.Application.Context.GetSystemService(Context.PowerService);

            if (_wakeLock == null)
            {
                _wakeLock = powerMgr.NewWakeLock(Android.OS.WakeLockFlags.Partial, typeof(SleepMode).FullName);
            }

            if (activateAutoSleepMode)
            {
                _wakeLock.Release();
            }
            else
            {
                _wakeLock.Acquire();
            }
        }
Esempio n. 8
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);
            RequestWindowFeature(WindowFeatures.NoTitle);
            Window.SetFlags(WindowManagerFlags.Fullscreen, WindowManagerFlags.Fullscreen);
            _glView = new GLSurfaceView(this);
            //mod
            //_glView.SetEGLConfigChooser (false);
            //_glView.SetEGLConfigChooser(8, 8, 8, 8, 0,0);

            _glView.SetRenderer(this);
            _input      = new AndroidInput(this, _glView, 1, 1);
            _file       = new AndroidFileIO(this.Assets);
            _audio      = new AndroidAudio(this);
            _glGraphics = new AndroidGLGraphics(_glView);
            SetContentView(_glView);
            PowerManager pm = (PowerManager)GetSystemService(Service.PowerService);

            _wakeLock = pm.NewWakeLock(WakeLockFlags.Full, "GLGame");
        }
Esempio n. 9
0
        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);

            //Hides the titlebar and sets the window to fullscreen
            RequestWindowFeature(WindowFeatures.NoTitle);
            Window.SetFlags(WindowManagerFlags.Fullscreen, WindowManagerFlags.Fullscreen);

            //Create a frameBuffer for the background
            var    rotation          = WindowManager.DefaultDisplay.Rotation;
            bool   isPortrait        = rotation == SurfaceOrientation.Rotation0 || rotation == SurfaceOrientation.Rotation180;
            int    frameBufferWidth  = isPortrait ? 480 : 800;
            int    frameBufferHeight = isPortrait ? 800 : 480;
            Bitmap frameBuffer       = Bitmap.CreateBitmap(frameBufferWidth, frameBufferHeight, Bitmap.Config.Rgb565);

            //Find screen size to calculate relative size
            var screenSize = new Point();

            WindowManager.DefaultDisplay.GetSize(screenSize);
            float scaleX = (float)frameBufferWidth / screenSize.X;
            float scaleY = (float)frameBufferHeight / screenSize.Y;

            //Generate classes and start-up the first screen
            renderView = new AndroidFastRenderView(this, frameBuffer);
            graphics   = new AndroidGraphics(Assets, frameBuffer);
            fileIO     = new AndroidFileIO(this);
            audio      = new AndroidAudio(this);
            input      = new AndroidInput(this, renderView, scaleX, scaleY);
            SetContentView(renderView);
            CurrentScreen = this.InitScreen;

            //Add a WakeLock to avoid the screen from going out
            PowerManager powerManager = (PowerManager)GetSystemService(Context.PowerService);

            wakeLock = powerManager.NewWakeLock(WakeLockFlags.Full, "BeerRun");
        }
Esempio n. 10
0
        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate (bundle);

            //Hides the titlebar and sets the window to fullscreen
            RequestWindowFeature (WindowFeatures.NoTitle);
            Window.SetFlags (WindowManagerFlags.Fullscreen, WindowManagerFlags.Fullscreen);

            //Create a frameBuffer for the background
            var rotation = WindowManager.DefaultDisplay.Rotation;
            bool isPortrait = rotation == SurfaceOrientation.Rotation0 || rotation == SurfaceOrientation.Rotation180;
            int frameBufferWidth = isPortrait ? 480 : 800;
            int frameBufferHeight = isPortrait ? 800 : 480;
            Bitmap frameBuffer = Bitmap.CreateBitmap (frameBufferWidth, frameBufferHeight, Bitmap.Config.Rgb565);

            //Find screen size to calculate relative size
            var screenSize = new Point();
            WindowManager.DefaultDisplay.GetSize(screenSize);
            float scaleX = (float)frameBufferWidth / screenSize.X;
            float scaleY = (float) frameBufferHeight / screenSize.Y;

            //Generate classes and start-up the first screen
            renderView = new AndroidFastRenderView (this, frameBuffer);
            graphics = new AndroidGraphics (Assets, frameBuffer);
            fileIO = new AndroidFileIO (this);
            audio = new AndroidAudio (this);
            input = new AndroidInput (this, renderView, scaleX, scaleY);
            SetContentView (renderView);
            CurrentScreen = this.InitScreen;

            //Add a WakeLock to avoid the screen from going out
            PowerManager powerManager = (PowerManager)GetSystemService (Context.PowerService);
            wakeLock = powerManager.NewWakeLock (WakeLockFlags.Full, "BeerRun");
        }
Esempio n. 11
0
		public static void Release() {
			if (wakeLock != null) wakeLock.Release(); wakeLock = null;
		}
Esempio n. 12
0
 /// <summary>
 /// Creates a WakeHolder object
 /// </summary>
 public WakeHolder()
 {
     Context context = Android.App.Application.Context;
     PowerManager pm = (PowerManager)context.GetSystemService(Context.PowerService);
     wakeLock = pm.NewWakeLock(WakeLockFlags.Partial, "Background Service Provided WakeLock");
     wakeLock.Acquire();
 }