Android Question [SOLVED] PhoneWakeState PartialLock & PhoneSensors when screen is off

lemonisdead

Well-Known Member
Licensed User
Longtime User
Hello,
I was reported an issue on a particular Samsung XCover 2 model (not all just one but not one phone only) : in an app, when the screen is put off using the power button, even if I had put the system on PartialLock, the PhoneSensors stop.

Previously, I had put a relaunch of the sensors when the screen was off and it worked great. But this time, it won't work.
Even, trying to provide my own screen lock (which reput on PartialLock) doesn't fix.

Of course, we have tried by deactivating any power saver features.

Please do you have any idea about ?
 

lemonisdead

Well-Known Member
Licensed User
Longtime User
Almost solved by adding a timer with a value of one second when the ScreenOff event has been received. When the timer ticks I stop and restart the sensors.
The main problem is that delay seems to be too long sometime. I empirically try to adjust it.
 
Upvote 0

Albert Lin

Member
Licensed User
Longtime User
Almost solved by adding a timer with a value of one second when the ScreenOff event has been received. When the timer ticks I stop and restart the sensors.
The main problem is that delay seems to be too long sometime. I empirically try to adjust it.

Hi, Try to do that, but it didn't work, What's wrong with it? please.

B4X:
Sub PE_ScreenOff (Intent As Intent)
    'ToastMessageShow("Screen is OFF",True)
    timer1.Enabled =True
End Sub
Sub Timer1_Tick
    timer1.Enabled=False
    sensor.StopListening
    'Common.Sleep(500)
    'sensor.StartListening("sensor")
    sensor.StartListening("sensor")
End Sub
 
Upvote 0

Sgardy

Member
Licensed User
Longtime User
Hi, Try to do that, but it didn't work, What's wrong with it? please.

B4X:
Sub PE_ScreenOff (Intent As Intent)
    'ToastMessageShow("Screen is OFF",True)
    timer1.Enabled =True
End Sub
Sub Timer1_Tick
    timer1.Enabled=False
    sensor.StopListening
    'Common.Sleep(500)
    'sensor.StartListening("sensor")
    sensor.StartListening("sensor")
End Sub

Because Timer doesn't works in sleep mode if I'm not wrong...
 
Upvote 0
Top