Android - How to deal with losing focus?

Previous topic - Next topic

planetm

One (or maybe two) more questions from me, I really appreciate the supportive nature of these forums, thank you for all your help!

How do you deal with your android games losing focus? If I switch to another app during my game, then when returning the game starts back on the main menu. I figure I need to use GLB_ON_PAUSE and GLB_ON_RESUME. Do I have to save all the variables and current game state to an .ini file or similar in GLB_ON_PAUSE then load it all in GLB_ON_RESUME or is there a simpler approach?

One other unrelated question: is there a way to add a hyperlink from my app to open a webpage in the browser?

Thanks,

Matt.

Schranz0r

maybe this? :

Code (glbasic) Select
AUTOPAUSE FALSE
I <3 DGArray's :D

PC:
AMD Ryzen 7 3800X 16@4.5GHz, 16GB Corsair Vengeance LPX DDR4-3200 RAM, ASUS Dual GeForce RTX™ 3060 OC Edition 12GB GDDR6, Windows 11 Pro 64Bit, MSi Tomahawk B350 Mainboard

planetm

Quote from: Schranz0r on 2012-Sep-02
maybe this? :

Code (glbasic) Select
AUTOPAUSE FALSE

Thanks for the reply. I gave this a try, but the app just freezes with a black screen when I return to it.

MrTAToad

Task switching in Android is not fully support in 10.283.  I think it is in the beta of V11, but never got around to testing it.

More about it here : http://www.glbasic.com/forum/index.php?topic=7901.msg66011#msg66011

spacefractal

#4
GLB_ON_RESUME is never invoked. This due neither onWindowFocusChanged() or onResume() is called in SDLActivity.java on resume. They only works if you leave the device and close its self.

Same behavier in v10 and the early v11 beta.

So until this got fixed, you should save when pause is invoked, which does call just before quit.
Genius.Greedy Mouse - Karma Miwa - Spot Race - CatchOut - PowerUp Elevation - The beagle Jam - Cave Heroes 2023 - https://spacefractal.itch.io/

planetm


planetm

Quote from: planetm on 2012-Sep-02
is there a way to add a hyperlink from my app to open a webpage in the browser?

Can anybody answer this question from my original post? I would like to add a couple of hyperlinks from my android app to various websites. How can I do it?

Thanks again,

Matt.

MrTAToad

The "easiest" way would be to use a font where all characters are underlined.  Detect a click between the x,y -> width, height and then call NETWEBEND

planetm

Thanks MrTAToad, don't know why i didn't find NETWEBEND myself :S