gap: "Turning screen off, haven't tried in mono for android, but in java
this works"

powerService.goToSleep( SystemClock.uptimeMillis() + 1 );


On 13 December 2012 10:33, Goncalo Oliveira <gonc...@minkan.net> wrote:

> Turning screen on you can use a wake lock
>
> wl = pm.NewWakeLock( WakeLockFlags.ScreenBright |
> WakeLockFlags.AcquireCausesWakeup, "your_tag_here" );
> wl.Acquire( 5000 ); // I used the timeout version here, but the other also
> works
>
> Just make sure you have the required permissions
>
>   <uses-permission android:name="android.permission.WAKE_LOCK" />
>   <uses-permission android:name="android.permission.DEVICE_POWER" />
>
> Turning screen off, haven't tried in mono for
>
>  powerService.goToSleep( SystemClock.uptimeMillis() + 1 );
>
>
>
> On 13 December 2012 09:01, Stephan Steiner <stephan.stei...@gmail.com>wrote:
>
>> Hi
>>
>> My app does telephony - so I need to turn on and off the display when the
>> proximity sensor detects that the phone is close to the user's face (and
>> with the screen off the device shouldn't react to the ear touching the
>> display). I got the proximity sensor bit down but having major issues
>> getting anything to work with regards to turning the screen on/off.
>>
>> First off, PowerManager.GoToSleep won't work due to security issues (even
>> though I gave my app the DEVICE_POWER permission)
>>
>> Using
>>
>> PowerManager manager =
>> (PowerManager)GetSystemService(Context.PowerService);
>>             myWakeLock = manager.NewWakeLock(WakeLockFlags.Partial, tag);
>> myWakeLock.Acquire()
>>
>> does nothing.
>>
>> WindowManagerLayoutParams layoutParams = Window.Attributes;
>> oldBrightness = layoutParams.ScreenBrightness;
>> layoutParams.ScreenBrightness = 0f;
>> layoutParams.Flags |= WindowManagerFlags.KeepScreenOn;
>> Window.Attributes = layoutParams;
>>
>> doesn't work either - 0 seems to be dimmed, but I need off (and disable
>> all
>> touch input) if I set  I suppose because ScreenBrightNess doesn't appear
>> to
>> be working (when the screen is on, brightness is still 0, even though if I
>> get the brightness from the system settings, it's 102 (I realize I need to
>> divide by 255 since for layout parameters the value is between 0 and 1).
>>
>> int oldBrightNess =
>> Android.Provider.Settings.System.GetInt(ContentResolver,
>> Android.Provider.Settings.System.ScreenBrightness);
>>
>> Does anybody have any bright (well... I need blacked out and bright) ideas
>> on how to solve this one?
>>
>> Regards
>> Stephan
>>
>>
>>
>> --
>> View this message in context:
>> http://mono-for-android.1047100.n5.nabble.com/Turning-display-on-and-off-tp5712611.html
>> Sent from the Mono for Android mailing list archive at Nabble.com.
>> _______________________________________________
>> Monodroid mailing list
>> Monodroid@lists.ximian.com
>>
>> UNSUBSCRIBE INFORMATION:
>> http://lists.ximian.com/mailman/listinfo/monodroid
>>
>
>
>
> --
> Gonçalo Oliveira
>



-- 
Gonçalo Oliveira
_______________________________________________
Monodroid mailing list
Monodroid@lists.ximian.com

UNSUBSCRIBE INFORMATION:
http://lists.ximian.com/mailman/listinfo/monodroid

Reply via email to