I’ve had this issue for a while now, when I press back button on any android device, I have to exit. It’s seems like this doing it in Java Layer.
I want SDL 2.0 Events to handle this, this way if someone press’s back, they can get back to Menu Screen and then Exit out of the Game.
What I would like to know, is how do i do this.
Get SDL 2.0 events to control the back_button
Then figure out a way for SDL events terminate the Java application ( like tell the Java application to terminate) something like this I have in my code. System.exit(0);
I’m suspecting I have to return false in the KeyEvent.KEYCODE_BACK code.
Then in SDL figure out when the back button is being pressed?
This basically just like exiting a game, but going to menu screen first.
Thanks Dudes.
// JAVA CODE
public boolean onKey(View v, int keyCode, KeyEvent event) {
I’ve had this issue for a while now, when I press back button on any
android device, I have to exit. It’s seems like this doing it in Java
Layer.
I want SDL 2.0 Events to handle this, this way if someone press’s back,
they can get back to Menu Screen and then Exit out of the Game.
What I would like to know, is how do i do this.
Get SDL 2.0 events to control the back_button
Look in SDL source code, in test/controllermap.c, search for
"SDLK_AC_BACK", you’ll see an example of how to get the back button key
presses.
Then figure out a way for SDL events terminate the Java application (
like tell the Java application to terminate) something like this I have in
my code. System.exit(0);
If you quit your app from the C side (return from main ), the Java side
will exit as well.
I had to update to last snapshot of the SDL 2.0 code also changed to a new Java file.
The events are workings now, but it seems like the Java Back and SDL back are working at the same time. As it now going back to the menu screen for a split second.
If I disable it to ignore the back button, SDL not longer receives it either.
I guess what i want is for SDL to receive but for Java to ignore.
I ended up going back to the old SDL source since the new Java file broke the layout of the screen also needed a new SDL source for it work.
The events work with both my applications, same SDL source and same Java file.
But one application works perfectly fine when hitting the back button, the other works for 1 second then exits.
I’m so baffled since the code is the same.
Finally fixed that issue by commenting out a few event checks.
The issue is now exiting out. since I’m using an older version of SDL 2.0 older Java file, I don’t think exit feature works. If i implement the new SDL source.
Means my screen-layout wouldn’t function. (Which means ADMOB won’t work)
" // Add to layout
LinearLayout root = (LinearLayout) findViewById(R.id.root);
LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.MATCH_PARENT);
root.addView(mSurface, lp);
"
Can’t believe something so simple on SDL PC computer, is thehardest thing on the Android.
Ok, I downloaded latest version of SDL via Planet Mercury!
Used the latest Java file, fixed up all the Layout and Ad’s
It’s working, the events, the back
Only one last problem, it’s exiting out of the application find. But the process seems to be still active, when you try loading it again. a It’s black screen.
I never tried exit(o); maybe it would of worked in the old SDL source file?
Even will all this updated, there seem to be on-pause issues. Doesn’t seem to be working 100%, but 97%. One phone has 50% major slow down in game, after return from onpause. The other 2 devices worked fine.
I never tried exit(o); maybe it would of worked in the old SDL source file?
Even will all this updated, there seem to be on-pause issues. Doesn’t seem
to be working 100%, but 97%. One phone has 50% major slow down in game,
after return from onpause. The other 2 devices worked fine.
Do not issue the exit command, that terminates all threads. Simply exit
from the main loop and the Java thread will detect that and terminate in
turn.–
Gabriel.
Btw. I’ve seen the audio thread of sdl mixer (at least the music) still
running even after the mainloop was left. Can anyone confirm?Am 31.12.2013 01:25 schrieb “Gabriel Jacobo” :
2013/12/28 Timodor
int main(int argc, char *argv[])
{
exit(0);
}
I didn’t call SDL exit
I never tried exit(o); maybe it would of worked in the old SDL source
file?
Even will all this updated, there seem to be on-pause issues. Doesn’t
seem to be working 100%, but 97%. One phone has 50% major slow down in
game, after return from onpause. The other 2 devices worked fine.
Do not issue the exit command, that terminates all threads. Simply exit
from the main loop and the Java thread will detect that and terminate in
turn.