The problem arises if the app loses focus once. Once it regains focus the screen background is always black. This happens in both an .apk and the AppGameKit Player
Note that the player app just has to lose focus once, and once that has happened even new broadcasts suffer the problem. To get SetScreenColor() to work again one has to
exit the player and start it again. (This is why yesterday I thought the Player was behaving differently to an .apk)
My sample code includes three buttons to show that SetScreenColor() does indeed (repeatedly) work initially.
Sample code:
// some buttons to change the screen color at run time
AddVirtualButton(1,20,25,20)
SetVirtualButtonText(1,"Red")
AddVirtualButton(2,50,25,20)
SetVirtualButtonText(2,"Green")
AddVirtualButton(3,80,25,20)
SetVirtualButtonText(3,"Blue")
do
If GetVirtualButtonPressed(1)
SetClearColor(255,0,0)
ClearScreen()
swap() // additional attempt to force it for blue
EndIf // red
If GetVirtualButtonPressed(2)
SetClearColor(0,255,0)
ClearScreen()
EndIf // green
If GetVirtualButtonPressed(3)
SetClearColor(0,0,255)
ClearScreen()
EndIf // blue
Sync()
loop
To witness the problem;
1) broadcast the code to Android (or install an apk of it)
2) click on the three buttons, background will change accordingly.
3) Switch away from the app
4) Switch back
On my Pixel 4a running Android 12, the screen is already black at that stage.
If you tap any of the buttons you see they change their shade
as if the background had changed. This tells us that the button code is being executed.
Adding
does not make a difference.
Perhaps this is a new behavior with Android 12 that people have not ben running into this problem more.