Android questions...

Previous topic - Next topic

ampos

-The BACK button quit my program. How to set it to "sleep" instead of "quit"?

-How do I read the Android buttons?

-Can I just change the .apk to .zip, remove a file from /media, and rename it again to .apk?

-How do I get the debug/stdout text?
check my web and/or my blog :D
http://diniplay.blogspot.com (devblog)
http://www.ampostata.org
http://ampostata.blogspot.com
I own PC-Win, MacBook 13", iPhone 3G/3GS/4G and iPAC-WinCE

Moebius

You can get STDOUT info by running "adb logcat".  This will show you the logs from the emulator/device in a console window.
If you want to implement your own use of the back button, you have to modify SDLActivity.java (in "distribute\Android\src\com\glbasic\test").  The back button is handled differently to other key presses, and you *should* be able to modify the code to send the back key like any other is, without GLB automatically closing.
You *can* change the .apk to a zip, but you should run the 'zipalign' program once you're done with it.  Google for more info (I don't know much about it...)
On reading the Android buttons, if you can't already get them using KEY (I haven't tried TBH), again you *might* be able to get them if you modify SDLActivity.java...
Endless Loop: n., see Loop, Endless.
Loop, Endless: n., see Endless Loop.
- Random Shack Data Processing Dictionary

ampos

Not very worried about the buttons, but I dont want my apps to quit when pressing "back" key.

I mean, other Android Apps are still there when pressing back and going again to the app.

But the GLB apps just close, so if I run the app again, it just load from the start.

In fact this is because my tablet has very sensitive buttons, I press/touch the back button almost all the time, and I dont want them to quit, just "sent back", as multitask on iOS4... Do I explain myself? :)
check my web and/or my blog :D
http://diniplay.blogspot.com (devblog)
http://www.ampostata.org
http://ampostata.blogspot.com
I own PC-Win, MacBook 13", iPhone 3G/3GS/4G and iPAC-WinCE

Moebius

If you want to make the back key accessible in GLB (and not just close the program), open SDLActivity.java, find the function "public boolean onKey", and delete the block of code that closes the program if the back button is pressed.  Then, KEY(4) should tell you if the back button is down.  And I take no responsibility for any horrible consequences of this  :whistle:
EDIT:
Code (glbasic) Select
public boolean onKey(View  v, int keyCode, KeyEvent event) {
// TRY DELETING THIS:
//--------------------------------------------------------------------------------------
if(keyCode==KeyEvent.KEYCODE_BACK)
{
// mActivity.glbasicOnPause(1);
mActivity.finish();
System.exit(0);
return super.onKeyDown(keyCode, event);
}
//------------------------------------------------------------------------------

        if (event.getAction() == KeyEvent.ACTION_DOWN) {
            Log.v("SDL", "key down: " + keyCode);
            SDLActivity.onNativeKeyDown(keyCode);
            return true;
        }
        else if (event.getAction() == KeyEvent.ACTION_UP) {
            //Log.v("SDL", "key up: " + keyCode);
            SDLActivity.onNativeKeyUp(keyCode);
            return true;
        }
       
        return false;
    }
Endless Loop: n., see Loop, Endless.
Loop, Endless: n., see Endless Loop.
- Random Shack Data Processing Dictionary

ampos

I dont want to access the back key. I want the back key to "sent back" my app, not quit it.

For example, Angry Birds. It is running. In half the action, I press the back key. It "closes" the app (really it is just hidden, as it can be seen running on the background by ES Task Manager). I press the Angry Bird icon again and the app is not loaded, it is just sent from the back to the front.

In my GLB app, if I press the back button, it is closed/killed. It is not running in the background. It is like if it reached a "END" instruction. I can not see it with Task Manager. If I press the app icon, the app is loaded again.

Sorry for my english.
check my web and/or my blog :D
http://diniplay.blogspot.com (devblog)
http://www.ampostata.org
http://ampostata.blogspot.com
I own PC-Win, MacBook 13", iPhone 3G/3GS/4G and iPAC-WinCE

Moebius

Oh - are you referring the home button?  Modifying "protected void onStop()" should work.  Try changing the "glbasicOnPause(-1)" to "glbasicOnPause(1)", which should call GLB_ON_PAUSE rather than quitting according to the comments.  Again, no guarantees horrible things won't happen, but that should make the home button pause rather than kill the app.
Endless Loop: n., see Loop, Endless.
Loop, Endless: n., see Endless Loop.
- Random Shack Data Processing Dictionary

ampos

Isn't this as easy as on iOS 4.x+? Have to test it then.

BTW, is Android 2.2 mandatory, or foes our Apps works on 2.1, 2.0,...?
check my web and/or my blog :D
http://diniplay.blogspot.com (devblog)
http://www.ampostata.org
http://ampostata.blogspot.com
I own PC-Win, MacBook 13", iPhone 3G/3GS/4G and iPAC-WinCE

Kitty Hello

did you try "ALLOWESCAPE TRUE; AUTOPAUSE TRUE;" ?

ampos

I think so, but I will check it later.
check my web and/or my blog :D
http://diniplay.blogspot.com (devblog)
http://www.ampostata.org
http://ampostata.blogspot.com
I own PC-Win, MacBook 13", iPhone 3G/3GS/4G and iPAC-WinCE

ampos

I can't get it to work.

ALLOWESCAPE TRUE/FALSE or AUTOPAUSE does no difference.

I did remove the lines, and then the BACK key does nothing, but the app is still on the front.

If I press the HOME button, the app is sent back and NOT killed, but after ON_RESUME, Android seems the app is not responding (and it isnt responding really) and close it.

The idea of removing the detection of BACK key could work if you want to implement in your game a MENU/BACK key system, calling END if the BACK key is pressed.

Gernot should fix the return of "sleep" apps sent to back with HOME key.

check my web and/or my blog :D
http://diniplay.blogspot.com (devblog)
http://www.ampostata.org
http://ampostata.blogspot.com
I own PC-Win, MacBook 13", iPhone 3G/3GS/4G and iPAC-WinCE

Kitty Hello

I think I did this, because when the App got focus it crashed. I try to see if I can fix it.

Mikele

#11
Hey

I have the same problem on Galaxy S. So, does it work or not?

Michal

msx


Kitty Hello

please keep with ALLOWESCAPE TRUE and act on GLB_ON_QUIT.