i have a application and now i want to add dim screen type of functionality in this feature application screen light gets dim according to given time and when user touch on screen it again resume. so please tell me how i can achieve it i have used this peace of code
time = 30000;
android.provider.Settings.System.putInt(getContentResolver(), Settings.System.SCREEN_OFF_TIMEOUT, time);
it is dim the screen but device is goes into sleep mode i dont want this situation please help me .
Related
I'm trying to get my Android app to keep the screen unlocked as long as the app is running. I easily solved this problem with setting this flag - WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON - in each activity.
But now I'd also like to allow the screen to dim and stay dimmed until a touch event is registered. I tried to mess with window object's screenBrightness and dimAmount but none of these worked (no changes in the brightness were made). Any ideas if I can implement this feature?
As a last resort I'd think a black dialog with alpha .5 covering the whole screen would work, but I don't know if this solution will have the same effect as an actual dim, battery-saving wise
I'm working on an application to record wounds with the camera2-api. For this I scan a qr-code with the patient data and then start to take picture of the wound. But when the activity (to take pictures) launches it seems like the screen gtes dimmed till I touch the screen and I dont know why
I think its up to the device because I use the same fragment for scanning and to take pictures and when I launch the ScanActivity the issue dosn't accure
What I have already tried
Change the display options of the device (brightness of the
screen adjust automatically to your environment).
Change the power saving mode activation time to 30 minutes
Set the AE state like this
captureRequestBuilder.set(CaptureRequest.CONTROL_AE_PRECAPTURE_TRIGGER,
CaptureRequest.CONTROL_AE_PRECAPTURE_TRIGGER_START);
and
getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
My questions
I'm not sure if the screen gets darker because of the exposure of the camera, the brightness of the screen or maybe the device switch to the
power saving mode.
How can i prevent that?
i got the solution. There was a AlertDialog without a view. At the begin i show the user the number of pictures but if the number is 0 no view added to the alert and that looks like the screen is dimming
I have a timer-like app, for which I want the screen to dim to the screen brightness minimum, after a certain amount of time but never go off.
The exact same behaviour as the android timer app does. I tried to look for the exact commands in the source code of the timer (link) but could not find it.
As far as I can tell when the timer is running and you are in the timer fragment the screen goes dim (darkened) 5 seconds before the screen time out time that has been set in the android settings. So for example, if you have set the screen timeout to 30 secs and you start the timer and do not touch the screen or press any button, the screen will go to minimum brightness after 25 seconds but the screen won't turn off. If you interact with the phone the screen goes to the preset brightness.
I want to replicate this exact behaviour and I think I have to use
window.attributes.screenBrightness == WindowManager.LayoutParams.BRIGHTNESS_OVERRIDE_OFF
and
override fun onUserInteraction()
but I am not sure how to time it.
Where can I find this behaviour in the source code of the android timer?
How can I replicate this behaviour?
For experiment/user study purpose, I need to keep my screen on for few minutes.
I have follow the guide from http://developer.android.com/training/wearables/apps/always-on.html and it works partially for my purpose.
The code allows my screen always on BUT it will enter ambient mode after few seconds. I DO NOT want ambient mode.
My trick is I commented out onEnterAmbient(), onUpdateAmbient() and onExitAmbient().
So that my screen drawing is still the same color (not changing to black & white).
HOWEVER the screen is DIMMED darker when entering ambient mode.
I don't want the DIMMED effect, I need to keep my screen as bright as possible for the duration of my user study.
Anyone has any clue?
You may try
getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
in your activity's onCreate() or use
android:keepScreenOn="true"
in your activity's layout. See this training material for details.
I'm trying to set System Screen Brightness instantaneously. I'm using a service to do that. Here it the code that I'm using.
Settings.System.putInt(cResolver,
Settings.System.SCREEN_BRIGHTNESS, 255);
This code works fine. But it is not instantaneous. The screen brightness value changes but the screen still looks dull. I can confirm this by reading back the screen brightness value and it is 255. If I lock the screen and come back, the screen is fully bright. How can I achieve this that the moment I set the system brightness to the maximum, I see fully bright screen?
BTW, I want to do this using a service and not an activity!
I would take a look at this link, specifically the first answer. It's a bit hackish though.
Changing screen brightness programmatically (as with the power widget)
Essentially you need to force the screen to refresh through starting a dummy activity and then finish() said dummy activity. I would have commented but I don't have enough points.