I run a small B4A app on my Samsung Galaxy Watch 6, which runs WearOS.
I have created a watchface that launches the app when the user taps a number onscreen. The app shows an image (a barcode).
I then wave that image at a scanner which reads the barcode.
When I tilt my hand down to the scanner, the watch screen dims which causes problems. To solve this I added PhoneWakeState.KeepAlive.
The problem is that, although I release the KeepAlive when the image app is closed, the watch seems to still be held awake.
Normally, I raise my wrist, the screen wakes up, then after 5 secs the screen dims again (to save battery). But after running this app, the screen just stays awake. It still dims if I turn my wrist downwards, but raising wrist again wakes the screen, and then it stays awake when it should dim after 5 secs.
In
138960, teddybear suggested adding the SetActivityAttribute(Main, android:keepScreenOn, "true") to manifest. I tried this but it does not keep the screen awake.
Its a standard Activity. I tried it using B4XPages, same.
Any ideas?
Sub Globals
Dim pws As PhoneWakeState
Private B4XImageView1 As B4XImageView
End Sub
Sub Activity_Create(FirstTime As Boolean)
Activity.LoadLayout("myimage")
B4XImageView1.Load(File.DirAssets, "myimage.jpg")
pws.KeepAlive(True)
End Sub
Sub Activity_Pause (UserClosed As Boolean)
If UserClosed Then
pws.ReleaseKeepAlive
End If
End Sub
Layout "myimage" just has a B4XImageView on it.