Watch, Follow, &
Connect with Us

For forums, blogs and more please visit our
Developer Tools Community.


Welcome, Guest
Guest Settings
Help

Thread: phone screen dims (beginning with Android 7)


This question is answered. Helpful answers available: 2. Correct answers available: 1.


Permlink Replies: 3 - Last Post: Jan 29, 2018 4:33 PM Last Post By: Jeremy North
Frank Yingst

Posts: 175
Registered: 1/19/05
phone screen dims (beginning with Android 7)  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Jan 22, 2018 2:15 PM
With Android 6 there is no problem but with Android 7 the phone dims even if I have the timeout set to a longer period. For example, if I set the timeout to 1 hour the phone dims after about 20-25 minutes. Just started with Android 7. The display stays on, just dimmer. The app claims the Brightness is still the same so the setting for this unwanted dimmer feature is something other than Brightness. Anyone have a solution?
Dave Nottage

Posts: 1,850
Registered: 1/7/00
Re: phone screen dims (beginning with Android 7) [Edit]  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Jan 23, 2018 12:03 PM   in response to: Frank Yingst in response to: Frank Yingst
Frank Yingst wrote:

With Android 6 there is no problem but with Android 7 the phone dims even if I have the timeout set to a longer
period. For example, if I set the timeout to 1 hour the phone dims after about 20-25 minutes. Just started with
Android 7. The display stays on, just dimmer. The app claims the Brightness is still the same so the setting for this
unwanted dimmer feature is something other than Brightness. Anyone have a solution?

You'll need to create a "wake lock", as per this suggestion:




uses
  Androidapi.JNI.Os, Androidapi.JNI.JavaTypes, Androidapi.Helpers, Androidapi.JNIBridge;
 
...
 
  FWakeLock: JPowerManager_WakeLock;
 
...
 
var
  LObject: JObject;
  LPowerManager: JPowerManager;
begin
  LObject := TAndroidHelper.Context.getSystemService(TJContext.JavaClass.POWER_SERVICE);
  if LObject <> nil then
  begin
    LPowerManager := TJPowerManager.Wrap((LObject as ILocalObject).GetObjectID);
    FWakeLock := LPowerManager.newWakeLock(TJPowerManager.JavaClass.SCREEN_DIM_WAKE_LOCK, StringToJString('My Tag'));
    FWakeLock.acquire;
  end;
end;


Remember to use FWakeLock.release when you need to.

--
Dave Nottage [MVP, TeamB]
Find hints, tips and tricks at Delphi Worlds blog: http://www.delphiworlds.com
Frank Yingst

Posts: 175
Registered: 1/19/05
Re: phone screen dims (beginning with Android 7) [Edit]  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Jan 27, 2018 3:32 PM   in response to: Dave Nottage in response to: Dave Nottage
I needed to set permission Wake lock to true. I will be testing further and see how it goes. Thanks.
Jeremy North

Posts: 402
Registered: 9/20/99
Re: phone screen dims (beginning with Android 7) [Edit]  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Jan 29, 2018 4:33 PM   in response to: Frank Yingst in response to: Frank Yingst
Frank Yingst wrote:
I needed to set permission Wake lock to true. I will be testing further and see how it goes. Thanks.

Yes because you app will use greater battery because it won't allow the screen to dim and users need to be made aware of this.
Legend
Helpful Answer (5 pts)
Correct Answer (10 pts)

Server Response from: ETNAJIVE02