Android Question API 36 Problem - Activity_Keypress event does not fire.

RichardN

Well-Known Member
Licensed User
Longtime User
I have a simple legacy calculator app (pre-B4X pages) that is sold the Play store. Google tell me that it needs to be updated to API36 before the end of August. It all seems to work aside from one glaring problem.... The Activity_Keypress event does not fire at all. The code is simple:

Activity_Keypress:
Sub Activity_KeyPress (KeyCode As Int) As Boolean     'Return True to consume the event
   
    Log("Some key is pressed...")
   
    If KeyCode = KeyCodes.KEYCODE_BACK Then
   
        If pnlResults.Visible = True Then
            pnlResults.Visible = False
            Return True
        End If
   
    End If
   
    Return False
           
End Sub

This all works fine with TargetSDK 35 compiling under that Javac but switching to Javac/SDK 36 the problem is immediately obvious. The log reports no activity from that Sub and the program exits as if the keystroke has not been handled. Any ideas?
 

Scantech

Well-Known Member
Licensed User
Longtime User
Perhaps a bit of customer feedback might actually be useful to @Erel ..... Just a thought!
I confirm this too. I tested it last year on emulator and i thought it was emulator issue. But today, i tested on samsung 24FE API 36 + Manifest and spotted the same issue.
 
Upvote 0

Scantech

Well-Known Member
Licensed User
Longtime User
Its my first time using Claude. Been using Gemini and chatgpt. Claude said put this in your manifest. It works! Temp Workaround until Erel resolves. it.

B4X:
SetApplicationAttribute(android:enableOnBackInvokedCallback, "false")

 
Last edited:
Upvote 1

drgottjr

Expert
Licensed User
Longtime User
with or without the manifest tweak, once you build with sdk36, you may find problems with older devices (eg sdk12) and with devices already running sdk17.
 
Upvote 0

RichardN

Well-Known Member
Licensed User
Longtime User
I am not tempted to code the program simply with a workaround. There will come a time when I have to issue yet another release removing the workround to replace it with the correct code.

We may also find out that there are other bugs arising from the new SDK that nobody has discovered yet.
 
Upvote 0

Zeev Goldstein

Well-Known Member
Licensed User
Longtime User
hi

had they same issue
once i got the beta for sdk36 it was gone and all works perfectlly
 
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…