Added a method in Java file which may be overridden for custom messages.
authorPhilipp Wiesemann <philipp.wiesemann@arcor.de>
Sun, 05 May 2013 12:53:57 +0200
changeset 7146 1968d3a85e35
parent 7145 4552268486f2
child 7147 370f207f24ec
Added a method in Java file which may be overridden for custom messages.
android-project/src/org/libsdl/app/SDLActivity.java
--- a/android-project/src/org/libsdl/app/SDLActivity.java	Sun May 05 12:50:34 2013 +0200
+++ b/android-project/src/org/libsdl/app/SDLActivity.java	Sun May 05 12:53:57 2013 +0200
@@ -114,6 +114,19 @@
     static final int COMMAND_UNUSED = 2;
     static final int COMMAND_TEXTEDIT_HIDE = 3;
 
+    protected static final int COMMAND_USER = 0x8000;
+
+    /**
+     * This method is called by SDL if SDL did not handle a message itself.
+     * This happens if a received message contains an unsupported command.
+     * Method can be overwritten to handle Messages in a different class.
+     * @param msg the Message which was not handled.
+     * @return if the Message was handled in method.
+     */
+    protected boolean onUnhandledMessage(Message msg) {
+        return false;
+    }
+
     /**
      * A Handler class for Messages from native SDL applications.
      * It uses current Activities as target (e.g. for the title).
@@ -143,6 +156,11 @@
                     imm.hideSoftInputFromWindow(mTextEdit.getWindowToken(), 0);
                 }
                 break;
+
+            default:
+                if ((context instanceof SDLActivity) && !((SDLActivity) context).onUnhandledMessage(msg)) {
+                    Log.e(TAG, "error handling message, command is " + msg.arg1);
+                }
             }
         }
     }