com.jme3.app
Class AndroidHarness

java.lang.Object
  extended by android.content.Context
      extended by android.content.ContextWrapper
          extended by android.view.ContextThemeWrapper
              extended by android.app.Activity
                  extended by com.jme3.app.AndroidHarness
All Implemented Interfaces:
android.content.ComponentCallbacks, android.content.DialogInterface.OnClickListener, android.view.KeyEvent.Callback, android.view.LayoutInflater.Factory, android.view.View.OnCreateContextMenuListener, android.view.Window.Callback, InputListener, TouchListener, SystemListener
Direct Known Subclasses:
DemoAndroidHarness

public class AndroidHarness
extends android.app.Activity
implements TouchListener, android.content.DialogInterface.OnClickListener, SystemListener

AndroidHarness wraps a jme application object and runs it on Android


Field Summary
protected  Application app
          The jme3 application object
protected  java.lang.String appClass
          The application class to start
protected  OGLESContext ctx
           
protected  AndroidConfigChooser.ConfigType eglConfigType
          ConfigType.FASTEST is RGB565, GLSurfaceView default ConfigType.BEST is RGBA8888 or better if supported by the hardware
protected  boolean eglConfigVerboseLogging
          If true all valid and not valid egl configs are logged
protected  java.lang.String exitDialogMessage
          Message of the exit dialog, default is "Use your home key to bring this app into the background or exit to terminate it."
protected  java.lang.String exitDialogTitle
          Title of the exit dialog, default is "Do you want to exit?"
protected  boolean finishOnAppStop
          if true finish this activity when the jme app is stopped
protected  android.widget.FrameLayout frameLayout
           
protected  boolean handleExitHook
          set to false if you don't want the harness to handle the exit hook
protected  boolean isGLThreadPaused
           
protected static java.util.logging.Logger logger
           
protected  boolean mouseEventsEnabled
          If true MouseEvents are generated from TouchEvents
protected  boolean mouseEventsInvertX
          Flip X axis
protected  boolean mouseEventsInvertY
          Flip Y axis
protected  boolean screenFullScreen
          Set the screen window mode.
protected  int screenOrientation
          Set the screen orientation, default is SENSOR ActivityInfo.SCREEN_ORIENTATION_* constants package android.content.pm.ActivityInfo SCREEN_ORIENTATION_UNSPECIFIED SCREEN_ORIENTATION_LANDSCAPE SCREEN_ORIENTATION_PORTRAIT SCREEN_ORIENTATION_USER SCREEN_ORIENTATION_BEHIND SCREEN_ORIENTATION_SENSOR (default) SCREEN_ORIENTATION_NOSENSOR
protected  boolean screenShowTitle
          if screenShowTitle is true while screenFullScreen is false, then the title bar is also displayed under the notification bar
protected  android.widget.ImageView splashImageView
           
protected  int splashPicID
          Splash Screen picture Resource ID.
protected  android.opengl.GLSurfaceView view
           
 
Fields inherited from class android.app.Activity
DEFAULT_KEYS_DIALER, DEFAULT_KEYS_DISABLE, DEFAULT_KEYS_SEARCH_GLOBAL, DEFAULT_KEYS_SEARCH_LOCAL, DEFAULT_KEYS_SHORTCUT, FOCUSED_STATE_SET, RESULT_CANCELED, RESULT_FIRST_USER, RESULT_OK
 
Fields inherited from class android.content.Context
ACCESSIBILITY_SERVICE, ACCOUNT_SERVICE, ACTIVITY_SERVICE, ALARM_SERVICE, AUDIO_SERVICE, BIND_AUTO_CREATE, BIND_DEBUG_UNBIND, BIND_NOT_FOREGROUND, CLIPBOARD_SERVICE, CONNECTIVITY_SERVICE, CONTEXT_IGNORE_SECURITY, CONTEXT_INCLUDE_CODE, CONTEXT_RESTRICTED, DEVICE_POLICY_SERVICE, DOWNLOAD_SERVICE, DROPBOX_SERVICE, INPUT_METHOD_SERVICE, KEYGUARD_SERVICE, LAYOUT_INFLATER_SERVICE, LOCATION_SERVICE, MODE_APPEND, MODE_PRIVATE, MODE_WORLD_READABLE, MODE_WORLD_WRITEABLE, NFC_SERVICE, NOTIFICATION_SERVICE, POWER_SERVICE, SEARCH_SERVICE, SENSOR_SERVICE, STORAGE_SERVICE, TELEPHONY_SERVICE, UI_MODE_SERVICE, VIBRATOR_SERVICE, WALLPAPER_SERVICE, WIFI_SERVICE, WINDOW_SERVICE
 
Constructor Summary
AndroidHarness()
           
 
Method Summary
 void destroy()
          Callback to indicate that the context has been destroyed (either by the user or requested by the application itself).
 void gainFocus()
          Called when the application gained focus.
 Application getJmeApplication()
           
 void handleError(java.lang.String errorMsg, java.lang.Throwable t)
          Called when an error has occurred.
 void initialize()
          Callback to indicate the application to initialize.
 void layoutDisplay()
           
 void loseFocus()
          Called when the application lost focus.
 void onClick(android.content.DialogInterface dialog, int whichButton)
          Called by the android alert dialog, terminate the activity and OpenGL rendering
 void onCreate(android.os.Bundle savedInstanceState)
           
protected  void onDestroy()
           
protected  void onPause()
           
protected  void onRestart()
           
protected  void onResume()
           
 java.lang.Object onRetainNonConfigurationInstance()
           
protected  void onStart()
           
protected  void onStop()
           
 void onTouch(java.lang.String name, TouchEvent evt, float tpf)
          Gets called by the InputManager on all touch/drag/scale events
 void removeSplashScreen()
           
 void requestClose(boolean esc)
          Called when the user requests to close the application.
 void reshape(int width, int height)
          Called to notify the application that the resolution has changed.
 void update()
          Callback to update the application state, and render the scene to the back buffer.
 
Methods inherited from class android.app.Activity
addContentView, closeContextMenu, closeOptionsMenu, createPendingResult, dismissDialog, dispatchKeyEvent, dispatchPopulateAccessibilityEvent, dispatchTouchEvent, dispatchTrackballEvent, findViewById, finish, finishActivity, finishActivityFromChild, finishFromChild, getApplication, getCallingActivity, getCallingPackage, getChangingConfigurations, getComponentName, getCurrentFocus, getInstanceCount, getIntent, getLastNonConfigurationInstance, getLayoutInflater, getLocalClassName, getMenuInflater, getParent, getPreferences, getRequestedOrientation, getSystemService, getTaskId, getTitle, getTitleColor, getVolumeControlStream, getWallpaperDesiredMinimumHeight, getWallpaperDesiredMinimumWidth, getWindow, getWindowManager, hasWindowFocus, isChild, isFinishing, isTaskRoot, managedQuery, moveTaskToBack, onActivityResult, onApplyThemeResource, onAttachedToWindow, onBackPressed, onChildTitleChanged, onConfigurationChanged, onContentChanged, onContextItemSelected, onContextMenuClosed, onCreateContextMenu, onCreateDescription, onCreateDialog, onCreateDialog, onCreateOptionsMenu, onCreatePanelMenu, onCreatePanelView, onCreateThumbnail, onCreateView, onDetachedFromWindow, onKeyDown, onKeyLongPress, onKeyMultiple, onKeyUp, onLowMemory, onMenuItemSelected, onMenuOpened, onNewIntent, onOptionsItemSelected, onOptionsMenuClosed, onPanelClosed, onPostCreate, onPostResume, onPrepareDialog, onPrepareDialog, onPrepareOptionsMenu, onPreparePanel, onRestoreInstanceState, onSaveInstanceState, onSearchRequested, onTitleChanged, onTouchEvent, onTrackballEvent, onUserInteraction, onUserLeaveHint, onWindowAttributesChanged, onWindowFocusChanged, openContextMenu, openOptionsMenu, overridePendingTransition, registerForContextMenu, removeDialog, requestWindowFeature, runOnUiThread, setContentView, setContentView, setContentView, setDefaultKeyMode, setFeatureDrawable, setFeatureDrawableAlpha, setFeatureDrawableResource, setFeatureDrawableUri, setIntent, setPersistent, setProgress, setProgressBarIndeterminate, setProgressBarIndeterminateVisibility, setProgressBarVisibility, setRequestedOrientation, setResult, setResult, setSecondaryProgress, setTitle, setTitle, setTitleColor, setVisible, setVolumeControlStream, showDialog, showDialog, startActivity, startActivityForResult, startActivityFromChild, startActivityIfNeeded, startIntentSender, startIntentSenderForResult, startIntentSenderFromChild, startManagingCursor, startNextMatchingActivity, startSearch, stopManagingCursor, takeKeyEvents, triggerSearch, unregisterForContextMenu
 
Methods inherited from class android.view.ContextThemeWrapper
attachBaseContext, getTheme, setTheme
 
Methods inherited from class android.content.ContextWrapper
bindService, checkCallingOrSelfPermission, checkCallingOrSelfUriPermission, checkCallingPermission, checkCallingUriPermission, checkPermission, checkUriPermission, checkUriPermission, clearWallpaper, createPackageContext, databaseList, deleteDatabase, deleteFile, enforceCallingOrSelfPermission, enforceCallingOrSelfUriPermission, enforceCallingPermission, enforceCallingUriPermission, enforcePermission, enforceUriPermission, enforceUriPermission, fileList, getApplicationContext, getApplicationInfo, getAssets, getBaseContext, getCacheDir, getClassLoader, getContentResolver, getDatabasePath, getDir, getExternalCacheDir, getExternalFilesDir, getFilesDir, getFileStreamPath, getMainLooper, getPackageCodePath, getPackageManager, getPackageName, getPackageResourcePath, getResources, getSharedPreferences, getWallpaper, grantUriPermission, isRestricted, openFileInput, openFileOutput, openOrCreateDatabase, peekWallpaper, registerReceiver, registerReceiver, removeStickyBroadcast, revokeUriPermission, sendBroadcast, sendBroadcast, sendOrderedBroadcast, sendOrderedBroadcast, sendStickyBroadcast, sendStickyOrderedBroadcast, setWallpaper, setWallpaper, startInstrumentation, startService, stopService, unbindService, unregisterReceiver
 
Methods inherited from class android.content.Context
getString, getString, getText, obtainStyledAttributes, obtainStyledAttributes, obtainStyledAttributes, obtainStyledAttributes
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

logger

protected static final java.util.logging.Logger logger

appClass

protected java.lang.String appClass
The application class to start


app

protected Application app
The jme3 application object


eglConfigType

protected AndroidConfigChooser.ConfigType eglConfigType
ConfigType.FASTEST is RGB565, GLSurfaceView default ConfigType.BEST is RGBA8888 or better if supported by the hardware


eglConfigVerboseLogging

protected boolean eglConfigVerboseLogging
If true all valid and not valid egl configs are logged


mouseEventsEnabled

protected boolean mouseEventsEnabled
If true MouseEvents are generated from TouchEvents


mouseEventsInvertX

protected boolean mouseEventsInvertX
Flip X axis


mouseEventsInvertY

protected boolean mouseEventsInvertY
Flip Y axis


finishOnAppStop

protected boolean finishOnAppStop
if true finish this activity when the jme app is stopped


handleExitHook

protected boolean handleExitHook
set to false if you don't want the harness to handle the exit hook


exitDialogTitle

protected java.lang.String exitDialogTitle
Title of the exit dialog, default is "Do you want to exit?"


exitDialogMessage

protected java.lang.String exitDialogMessage
Message of the exit dialog, default is "Use your home key to bring this app into the background or exit to terminate it."


screenFullScreen

protected boolean screenFullScreen
Set the screen window mode. If screenFullSize is true, then the notification bar and title bar are removed and the screen covers the entire display.   If screenFullSize is false, then the notification bar remains visible if screenShowTitle is true while screenFullScreen is false, then the title bar is also displayed under the notification bar.


screenShowTitle

protected boolean screenShowTitle
if screenShowTitle is true while screenFullScreen is false, then the title bar is also displayed under the notification bar


splashPicID

protected int splashPicID
Splash Screen picture Resource ID. If a Splash Screen is desired, set splashPicID to the value of the Resource ID (i.e. R.drawable.picname). If splashPicID = 0, then no splash screen will be displayed.


screenOrientation

protected int screenOrientation
Set the screen orientation, default is SENSOR ActivityInfo.SCREEN_ORIENTATION_* constants package android.content.pm.ActivityInfo SCREEN_ORIENTATION_UNSPECIFIED SCREEN_ORIENTATION_LANDSCAPE SCREEN_ORIENTATION_PORTRAIT SCREEN_ORIENTATION_USER SCREEN_ORIENTATION_BEHIND SCREEN_ORIENTATION_SENSOR (default) SCREEN_ORIENTATION_NOSENSOR


ctx

protected OGLESContext ctx

view

protected android.opengl.GLSurfaceView view

isGLThreadPaused

protected boolean isGLThreadPaused

splashImageView

protected android.widget.ImageView splashImageView

frameLayout

protected android.widget.FrameLayout frameLayout
Constructor Detail

AndroidHarness

public AndroidHarness()
Method Detail

onRetainNonConfigurationInstance

public java.lang.Object onRetainNonConfigurationInstance()
Overrides:
onRetainNonConfigurationInstance in class android.app.Activity

onCreate

public void onCreate(android.os.Bundle savedInstanceState)
Overrides:
onCreate in class android.app.Activity

onRestart

protected void onRestart()
Overrides:
onRestart in class android.app.Activity

onStart

protected void onStart()
Overrides:
onStart in class android.app.Activity

onResume

protected void onResume()
Overrides:
onResume in class android.app.Activity

onPause

protected void onPause()
Overrides:
onPause in class android.app.Activity

onStop

protected void onStop()
Overrides:
onStop in class android.app.Activity

onDestroy

protected void onDestroy()
Overrides:
onDestroy in class android.app.Activity

getJmeApplication

public Application getJmeApplication()

handleError

public void handleError(java.lang.String errorMsg,
                        java.lang.Throwable t)
Called when an error has occurred. By default, will show an error message to the user and print the exception/error to the log.

Specified by:
handleError in interface SystemListener
Parameters:
errorMsg - The error message, if any, or null.
t - Throwable object, or null.

onClick

public void onClick(android.content.DialogInterface dialog,
                    int whichButton)
Called by the android alert dialog, terminate the activity and OpenGL rendering

Specified by:
onClick in interface android.content.DialogInterface.OnClickListener
Parameters:
dialog -
whichButton -

onTouch

public void onTouch(java.lang.String name,
                    TouchEvent evt,
                    float tpf)
Gets called by the InputManager on all touch/drag/scale events

Specified by:
onTouch in interface TouchListener
Parameters:
name - the name of the event
evt - the touch event
tpf - how much time has passed since the last frame

layoutDisplay

public void layoutDisplay()

removeSplashScreen

public void removeSplashScreen()

initialize

public void initialize()
Description copied from interface: SystemListener
Callback to indicate the application to initialize. This method is called in the GL/Rendering thread so any GL-dependent resources can be initialized.

Specified by:
initialize in interface SystemListener

reshape

public void reshape(int width,
                    int height)
Description copied from interface: SystemListener
Called to notify the application that the resolution has changed.

Specified by:
reshape in interface SystemListener

update

public void update()
Description copied from interface: SystemListener
Callback to update the application state, and render the scene to the back buffer.

Specified by:
update in interface SystemListener

requestClose

public void requestClose(boolean esc)
Description copied from interface: SystemListener
Called when the user requests to close the application. This could happen when he clicks the X button on the window, presses the Alt-F4 combination, attempts to shutdown the process from the task manager, or presses ESC.

Specified by:
requestClose in interface SystemListener
Parameters:
esc - If true, the user pressed ESC to close the application.

destroy

public void destroy()
Description copied from interface: SystemListener
Callback to indicate that the context has been destroyed (either by the user or requested by the application itself). Typically cleanup of native resources should happen here. This method is called in the GL/Rendering thread.

Specified by:
destroy in interface SystemListener

gainFocus

public void gainFocus()
Description copied from interface: SystemListener
Called when the application gained focus. The display implementation is not allowed to call this method before initialize() has been called or after destroy() has been called.

Specified by:
gainFocus in interface SystemListener

loseFocus

public void loseFocus()
Description copied from interface: SystemListener
Called when the application lost focus. The display implementation is not allowed to call this method before initialize() has been called or after destroy() has been called.

Specified by:
loseFocus in interface SystemListener