I Do not know how to do it, help me please? :nw:
This java
@Override
public void onBackPressed() {
// TODO Auto-generated method stub
// super.onBackPressed();
openQuitDialog(); - THIS SHOULD BE CHANGED TO CALL -(ON/OFF)
}
How can I do
?IFDEF ANDROID
IMPORT "C" const char* android_JAVACALL(const char* string)
?ENDIF
FUNCTION JavaCall$: callStr$
?IFDEF ANDROID
IF adService.state=1 THEN RETURN
STATIC res$
res$ = android_JAVACALL(callStr$)
RETURN res$
?ENDIF
ENDFUNCTION
HELP PLEASE :nw:
I do like this
FUNCTION onBackPressed:
LOCAL res$ = JavaCall$("onBackPressed:")
IF (res$ = "true" OR res$ = "TRUE")
RETURN TRUE
ELSE
RETURN FALSE
ENDIF
ENDFUNCTION
but it does not work IF (onBackPressed()=TRUE);success$="it works";ENDIF
I know that it is necessary to add a Java method, the same place where
FUNCTION isReloadTextures:
LOCAL res$ = JavaCall$("isReloadTextures:")
IF (res$ = "true" OR res$ = "TRUE")
RETURN TRUE
ELSE
RETURN FALSE
ENDIF
ENDFUNCTION
how to do it :nw: :giveup:
I´m pretty interested in knowing too, but check android extras threads by spacefractal there is a download and manual teaching how to do so. :good:
I did it
It may be added after compilation - distribute\Android\src\com\glbasic\test\SDLActivity.java
Or must be added in a future release
See attached files
with android extras, the back button can been checked in this way:
ALLOWESCAPE FALSE
If KEY(1)=true THEN
There was few issues in Stock glbasic, but was fixed in Android extras around v2.7+, where I'm began to fix some official commands as well like the first command to enable/disable back button.
it is necessary to disable the back button
and further
IF (Android.onBackUp()=TRUE);successUp$="it works";ENDIF
//////////////////
// ---------------------[on BACK Up BUTTONS ]---------------------
FUNCTION onBackUp:
LOCAL res$ = JavaCall$("onBackUp:")
IF (res$ = "true" OR res$ = "TRUE")
RETURN TRUE
ELSE
RETURN FALSE
ENDIF
ENDFUNCTION
See the attached file
replace onBackPressed
on onBackDown
Is wrote previous, it's allready implemented in a different way.
I'm added those in onKeyDown() and onKeyUp(), because im did have some issues with the onBack function in Java, which did not fired correctly in some cases.
Since Android Extras around 2.7+, then you can uses ALLOWESCAPE for enable and disable the back button. Then its can been checked by KEY(1), which is designed as a clicked event. If you want it to checked if pressed or not by your self, then uses KEY(4) instead.
You might require Android Extras 2.7+ for above after im fixed various issue with the back button in the stock glbasic, so its did not work correctly (etc ALLOWESCAPE does call java to enable/disable the button).
I do not know how to turn on turn off
// ---------------------[ Enable Lock Screen - screen timeout on/off]---------------------
FUNCTION EnableLockScreen: yes=TRUE
IF yes=TRUE
JavaCall$("enableLockScreen:true") // or 1-true
ELSE
JavaCall$("enableLockScreen:false") // or num%-false
ENDIF
ENDFUNCTION
simply turned off the :nw:
enableLockScreen() can been added to next version of AE, credited to you. But keep that turned on ONLY in gameplay, not in menu to save battery. Often there is newer a problem not turned it off, but im add this to next version of AE, and the function of course credited to you.
But there is no reason to add the back key functions, since its allready covered by AE using official commands (since ALLOWESCAPE calls the java function directly).
PS. im thinks the Lockscreen() was removed due some techincal issues with some older devices. Its was normally turned on from start. So its can been a reason it got removed.
Hi
Would such a function be a solution for my continuous problem with the Amazon Hibernate button??
When I press power button and screen goes black the game is not pausing and still playing away as if nothing happened...
Still have that issue? Can't do anything more since it's does nice here and won't blindfix it. You eventually need to pm a project...
I disabled "gamestick" and earned a button. The button does not work BACK when it starts works "gamestick". We need to find and wipe off the problem that can to be able to connect properly without tripping BACK button.
Not sure what you meant really?
Actually the game controller code should not interfere the back button at all, since they KEY() is sent first. The game controller code was designed with Ouya, Mojo and GameStick android game consoles in mind.
All key scancodes is done and checked in onkeydown() and onkeyup() functions, which is also include the Back button.
Im did this in public boolean onKeyDown(int keyCode, KeyEvent event):
SDLActivity.onGlbasicKeyDown(keyCode);
if (keyCode == KeyEvent.KEYCODE_BACK) SDLActivity.onGlbasicKeyDown(1);
SDLActivity.onGlbasicKeyDown(1) send a pressed down code to the KEY(1) command, which is a regular glbasic comand. Its also send the regular scancode, unchanged.
This is why you just could do a ALLOWESCAPE FALSE (ALLOWESCAPE command send directly to the "enableBack" java vommand, done in c++) and then using KEY(1) for checking the back button. This would been the most compatible method to do that. KEY(1) is on windows also the Escape button.
must also
Code: GLBasic [Select]
SDLActivity.onGlbasicKeyUp(keyCode);
if (keyCode == KeyEvent.KEYCODE_BACK) SDLActivity.onGlbasicKeyUp(1);
im reset KEY(1) in sdl_main.cpp (see int AndroidScancode(int skey)), soon after KEY(1) have been checked and its once have been returned TRUE. If you want the original Back event, uses KEY(4) instead.
This is the fun part, when you mix Java and C++ code.
That was make sure there dont happens something accidently when user holding down the back button as its should not.