Results 1 to 4 of 4

Thread: Android back button

  1. #1
    Squire
    Join Date
    Apr 2011
    Posts
    26

    Default Android back button

    Is there any other way to use the physical back button beside connecting it to an onscreen button?
    And is there any way to enable the button in other activities? I can switch between proton and android activities in the same app, but the back button doesn't work in the android activities. I presume you disabled it to prevent it quitting proton apps outright, but I need it enabled here as this part of my app works like android was designed.

  2. #2
    Administrator Seth's Avatar
    Join Date
    Jul 2002
    Location
    Japan
    Posts
    5,380

    Default

    The back button triggers BaseApp::m_sig_input() with a parm1 value of VIRTUAL_KEY_BACK.

    I do signal on the Java side that "we handled it" - this may be causing you problems..

    SharedActivity.java does it this way (and similar for onKeyUp as well)

    (look at the case KeyEvent.KEYCODE_BACK, that's where it is..)

    Code:
    public boolean onKeyDown(int keycode, KeyEvent e) 
    	 {
      //     Log.v("onKeyDown","Keydown Got "+keycode+" "+Character.toString(Character.toChars(e.getUnicodeChar())[0]));
       
    	
    		if (e.getRepeatCount() > 0) return super.onKeyDown(keycode, e);
    
    
            switch (keycode)
    		{
    			case KeyEvent.KEYCODE_BACK:
    			{
    				//Log.v("onKeyDown","Sending virtual back");
    				nativeOnKey(1, VIRTUAL_KEY_BACK, e.getUnicodeChar()); 
    				return true; //signal that we handled it
    			}
    		}
    		
    		int vKey = TranslateKeycodeToProtonVirtualKey(keycode);
    		nativeOnKey(1, vKey,e.getUnicodeChar()); //1  means keydown
            return super.onKeyDown(keycode, e);
        }
    So perhaps instead of

    return true; //signal that we handled it

    you need:

    return super.onKeyDown(keycode, e);

    ?

    If you can verify that fixes it, I could add a way to turn on that behavior on/off or something so you don't have to maintain your own version of SharedActivity.java for it.
    Seth A. Robinson
    Robinson Technologies

  3. #3
    Administrator Seth's Avatar
    Join Date
    Jul 2002
    Location
    Japan
    Posts
    5,380

    Default

    Is there any other way to use the physical back button beside connecting it to an onscreen button?
    Oh, to answer this - yes, it doesn't need to be connected to an actual button, the RTBareBones example connects to it a function. (OnExitApp or something)
    Seth A. Robinson
    Robinson Technologies

  4. #4
    Squire
    Join Date
    Apr 2011
    Posts
    26

    Default

    Apparently the back button is also connected to a function in all of the mainmenu examples, I don't know how I missed that until now. But it's not exactly working right if I use it in other screens. It calls the function I assigned which quits to the previous screen (currently basically a copy of mainmenu from one of the examples) but the button instantly activates the function that back is connected to there as well, quitting the app. With AddHotKeyToButton, that doesn't happen.

    And yes, with those changes (just disabling what you had, only keeping the last line) using the back button in another activity works as android was designed, ie it stops and goes back to the previous activity.

Similar Threads

  1. Button Bug?
    By madmark in forum Official ClanLib SDK Forums
    Replies: 0
    Last Post: 02-10-2009, 08:33 PM
  2. Button ID
    By madmark in forum Official ClanLib SDK Forums
    Replies: 2
    Last Post: 09-25-2007, 09:09 PM
  3. A while back...
    By phil712 in forum Dink Smallwood HD
    Replies: 0
    Last Post: 01-10-2006, 08:00 AM
  4. fqmods.cjb.net back with some new stuff.
    By in forum Funeral Quest
    Replies: 4
    Last Post: 10-20-2004, 05:25 PM
  5. FQ licensing server back up
    By Seth in forum Funeral Quest
    Replies: 2
    Last Post: 02-05-2004, 02:38 PM

Bookmarks

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •