Author Topic: Android back button  (Read 655 times)

Offline MrPlow

  • Prof. Inline
  • *****
  • Posts: 1784
    • View Profile
Android back button
« on: 2020-Apr-12 »
Hi Guys

Noticed something on this and wanted to offer tip on using Android Back button...

If using multiple KEY(1) to test for back presses, use it once per loop and store in variable.

As I found KEY(1) did not detect on my second statement - gave me a headache for few hours before I copped the issue.

Code: (glbasic) [Select]
LOCAL getbackkey = KEY(1)

IF getbackkey AND...

IF getbackkey AND ...

Comp:
Speccy-48k, Speccy-128k, Amigas, PCs

Offline spacefractal

  • Community Developer
  • Prof. Inline
  • ******
  • Posts: 3955
    • View Profile
    • Space Fractal
Re: Android back button
« Reply #1 on: 2020-Apr-12 »
If im remember right, KEY(1) only detect once per press. So its a toggle key. So its return to zero soon after use.

This has allways been that since Android SDK version and im did not change that to Android Studio. Not sure im should have do that throught. But this has been on in years really!

This is so you dont accidently activate the back button twice to suddently quit the game instead.
« Last Edit: 2020-Apr-12 by spacefractal »
Genius.Greedy Mouse - Karma Miwa - Spot Race - CatchOut - PowerUp Elevation and The beagle Jam.

Offline MrPlow

  • Prof. Inline
  • *****
  • Posts: 1784
    • View Profile
Re: Android back button
« Reply #2 on: 2020-Apr-13 »
Yes, that is fine...I can see the logic :)

I wansn't sure it was meant - as I previously used AE ("menu") command to do my other back button presses.

But only only once per loop is fine.
It was just that testing for the keypress would fail for subsequent tries in multiple 'IF' tests and I wanted to help others - in case they tried the same :)
Comp:
Speccy-48k, Speccy-128k, Amigas, PCs