Package com.jme3.app
Class AndroidHarness
java.lang.Object
android.content.Context
android.content.ContextWrapper
android.view.ContextThemeWrapper
android.app.Activity
com.jme3.app.AndroidHarness
- All Implemented Interfaces:
- android.content.ComponentCallbacks,- android.content.ComponentCallbacks2,- android.content.DialogInterface.OnClickListener,- android.view.KeyEvent.Callback,- android.view.LayoutInflater.Factory,- android.view.LayoutInflater.Factory2,- android.view.View.OnCreateContextMenuListener,- android.view.Window.Callback,- InputListener,- TouchListener,- SystemListener
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 SummaryFieldsModifier and TypeFieldDescriptionprotected LegacyApplicationThe jme3 application objectprotected StringThe application class to startprotected StringSets the type of Audio Renderer to be used.protected OGLESContextprotected intSets the desired number of Alpha bits for the surfaceview.protected intSets the desired RGB size for the surfaceview.protected intThe number of depth bits specifies the precision of the depth buffer.protected intSets the number of samples to use for multisampling.
 Leave 0 (default) to disable multisampling.
 Set to 2 or 4 to enable multisampling.protected intSet the number of stencil bits.protected StringMessage of the exit dialog, default is "Use your home key to bring this app into the background or exit to terminate it."protected StringTitle of the exit dialog, default is "Do you want to exit?"protected booleanif true finish this activity when the jme app is stoppedprotected android.widget.FrameLayoutprotected intSet the desired frame rate.protected booleanset to false if you don't want the harness to handle the exit hookprotected booleanprotected booleanIf true Android Sensors are used as simulated Joysticks.protected booleanIf true KeyEvents are generated from TouchEventsprotected static final Loggerprotected booleanIf true MouseEvents are generated from TouchEventsprotected booleanFlip X axisprotected booleanFlip Y axisprotected booleanSet the screen window mode.protected booleanif screenShowTitle is true while screenFullScreen is false, then the title bar is also displayed under the notification barprotected android.widget.ImageViewprotected intSplash Screen picture Resource ID.protected android.opengl.GLSurfaceViewFields inherited from class android.app.ActivityDEFAULT_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_OKFields inherited from class android.content.ContextACCESSIBILITY_SERVICE, ACCOUNT_SERVICE, ACTIVITY_SERVICE, ALARM_SERVICE, APP_OPS_SERVICE, APPWIDGET_SERVICE, AUDIO_SERVICE, BATTERY_SERVICE, BIND_ABOVE_CLIENT, BIND_ADJUST_WITH_ACTIVITY, BIND_ALLOW_OOM_MANAGEMENT, BIND_AUTO_CREATE, BIND_DEBUG_UNBIND, BIND_EXTERNAL_SERVICE, BIND_IMPORTANT, BIND_NOT_FOREGROUND, BIND_WAIVE_PRIORITY, BLUETOOTH_SERVICE, CAMERA_SERVICE, CAPTIONING_SERVICE, CARRIER_CONFIG_SERVICE, CLIPBOARD_SERVICE, COMPANION_DEVICE_SERVICE, CONNECTIVITY_SERVICE, CONSUMER_IR_SERVICE, CONTEXT_IGNORE_SECURITY, CONTEXT_INCLUDE_CODE, CONTEXT_RESTRICTED, CROSS_PROFILE_APPS_SERVICE, DEVICE_POLICY_SERVICE, DISPLAY_SERVICE, DOWNLOAD_SERVICE, DROPBOX_SERVICE, EUICC_SERVICE, FINGERPRINT_SERVICE, HARDWARE_PROPERTIES_SERVICE, INPUT_METHOD_SERVICE, INPUT_SERVICE, IPSEC_SERVICE, JOB_SCHEDULER_SERVICE, KEYGUARD_SERVICE, LAUNCHER_APPS_SERVICE, LAYOUT_INFLATER_SERVICE, LOCATION_SERVICE, MEDIA_PROJECTION_SERVICE, MEDIA_ROUTER_SERVICE, MEDIA_SESSION_SERVICE, MIDI_SERVICE, MODE_APPEND, MODE_ENABLE_WRITE_AHEAD_LOGGING, MODE_MULTI_PROCESS, MODE_NO_LOCALIZED_COLLATORS, MODE_PRIVATE, MODE_WORLD_READABLE, MODE_WORLD_WRITEABLE, NETWORK_STATS_SERVICE, NFC_SERVICE, NOTIFICATION_SERVICE, NSD_SERVICE, POWER_SERVICE, PRINT_SERVICE, RECEIVER_VISIBLE_TO_INSTANT_APPS, RESTRICTIONS_SERVICE, SEARCH_SERVICE, SENSOR_SERVICE, SHORTCUT_SERVICE, STORAGE_SERVICE, STORAGE_STATS_SERVICE, SYSTEM_HEALTH_SERVICE, TELECOM_SERVICE, TELEPHONY_SERVICE, TELEPHONY_SUBSCRIPTION_SERVICE, TEXT_CLASSIFICATION_SERVICE, TEXT_SERVICES_MANAGER_SERVICE, TV_INPUT_SERVICE, UI_MODE_SERVICE, USAGE_STATS_SERVICE, USB_SERVICE, USER_SERVICE, VIBRATOR_SERVICE, WALLPAPER_SERVICE, WIFI_AWARE_SERVICE, WIFI_P2P_SERVICE, WIFI_RTT_RANGING_SERVICE, WIFI_SERVICE, WINDOW_SERVICEFields inherited from interface android.content.ComponentCallbacks2TRIM_MEMORY_BACKGROUND, TRIM_MEMORY_COMPLETE, TRIM_MEMORY_MODERATE, TRIM_MEMORY_RUNNING_CRITICAL, TRIM_MEMORY_RUNNING_LOW, TRIM_MEMORY_RUNNING_MODERATE, TRIM_MEMORY_UI_HIDDEN
- 
Constructor SummaryConstructors
- 
Method SummaryModifier and TypeMethodDescriptionvoiddestroy()Callback to indicate that the context has been destroyed (either by the user or requested by the application itself).voidCalled when the application gained focus.voidhandleError(String errorMsg, Throwable t) Called when an error has occurred.voidCallback to indicate the application to initialize.protected voidRemoves the standard Android log handler due to an issue with not logging entries lower than INFO level and adds a handler that produces JME formatted log messages.voidvoidCalled when the application lost focus.voidonClick(android.content.DialogInterface dialog, int whichButton) Called by the android alert dialog, terminate the activity and OpenGL renderingvoidonCreate(android.os.Bundle savedInstanceState) protected voidprotected voidonPause()protected voidprotected voidonResume()protected voidonStart()protected voidonStop()voidonTouch(String name, TouchEvent evt, float tpf) Gets called by the InputManager on all touch/drag/scale eventsvoidvoidrequestClose(boolean esc) Called when the user requests to close the application.voidrescale(float x, float y) Called to notify the application that the scale has changed.voidreshape(int width, int height) Called to notify the application that the resolution has changed.voidupdate()Callback to update the application state, and render the scene to the back buffer.Methods inherited from class android.app.ActivityaddContentView, attachBaseContext, closeContextMenu, closeOptionsMenu, createPendingResult, dismissDialog, dismissKeyboardShortcutsHelper, dispatchGenericMotionEvent, dispatchKeyEvent, dispatchKeyShortcutEvent, dispatchPopulateAccessibilityEvent, dispatchTouchEvent, dispatchTrackballEvent, dump, enterPictureInPictureMode, enterPictureInPictureMode, findViewById, finish, finishActivity, finishActivityFromChild, finishAffinity, finishAfterTransition, finishAndRemoveTask, finishFromChild, getActionBar, getApplication, getCallingActivity, getCallingPackage, getChangingConfigurations, getComponentName, getContentScene, getContentTransitionManager, getCurrentFocus, getFragmentManager, getIntent, getLastNonConfigurationInstance, getLayoutInflater, getLoaderManager, getLocalClassName, getMaxNumPictureInPictureActions, getMediaController, getMenuInflater, getParent, getParentActivityIntent, getPreferences, getReferrer, getRequestedOrientation, getSearchEvent, getSystemService, getTaskId, getTitle, getTitleColor, getVoiceInteractor, getVolumeControlStream, getWindow, getWindowManager, hasWindowFocus, invalidateOptionsMenu, isActivityTransitionRunning, isChangingConfigurations, isChild, isDestroyed, isFinishing, isImmersive, isInMultiWindowMode, isInPictureInPictureMode, isLocalVoiceInteractionSupported, isTaskRoot, isVoiceInteraction, isVoiceInteractionRoot, managedQuery, moveTaskToBack, navigateUpTo, navigateUpToFromChild, onActionModeFinished, onActionModeStarted, onActivityReenter, onActivityResult, onApplyThemeResource, onAttachedToWindow, onAttachFragment, onBackPressed, onChildTitleChanged, onConfigurationChanged, onContentChanged, onContextItemSelected, onContextMenuClosed, onCreate, onCreateContextMenu, onCreateDescription, onCreateDialog, onCreateDialog, onCreateNavigateUpTaskStack, onCreateOptionsMenu, onCreatePanelMenu, onCreatePanelView, onCreateThumbnail, onCreateView, onCreateView, onDetachedFromWindow, onEnterAnimationComplete, onGenericMotionEvent, onKeyDown, onKeyLongPress, onKeyMultiple, onKeyShortcut, onKeyUp, onLocalVoiceInteractionStarted, onLocalVoiceInteractionStopped, onLowMemory, onMenuItemSelected, onMenuOpened, onMultiWindowModeChanged, onMultiWindowModeChanged, onNavigateUp, onNavigateUpFromChild, onNewIntent, onOptionsItemSelected, onOptionsMenuClosed, onPanelClosed, onPictureInPictureModeChanged, onPictureInPictureModeChanged, onPostCreate, onPostCreate, onPostResume, onPrepareDialog, onPrepareDialog, onPrepareNavigateUpTaskStack, onPrepareOptionsMenu, onPreparePanel, onProvideAssistContent, onProvideAssistData, onProvideKeyboardShortcuts, onProvideReferrer, onRequestPermissionsResult, onRestoreInstanceState, onRestoreInstanceState, onSaveInstanceState, onSaveInstanceState, onSearchRequested, onSearchRequested, onStateNotSaved, onTitleChanged, onTouchEvent, onTrackballEvent, onTrimMemory, onUserInteraction, onUserLeaveHint, onVisibleBehindCanceled, onWindowAttributesChanged, onWindowFocusChanged, onWindowStartingActionMode, onWindowStartingActionMode, openContextMenu, openOptionsMenu, overridePendingTransition, postponeEnterTransition, recreate, registerForContextMenu, releaseInstance, removeDialog, reportFullyDrawn, requestDragAndDropPermissions, requestPermissions, requestShowKeyboardShortcuts, requestVisibleBehind, requestWindowFeature, requireViewById, runOnUiThread, setActionBar, setContentTransitionManager, setContentView, setContentView, setContentView, setDefaultKeyMode, setEnterSharedElementCallback, setExitSharedElementCallback, setFeatureDrawable, setFeatureDrawableAlpha, setFeatureDrawableResource, setFeatureDrawableUri, setFinishOnTouchOutside, setImmersive, setIntent, setMediaController, setPictureInPictureParams, setProgress, setProgressBarIndeterminate, setProgressBarIndeterminateVisibility, setProgressBarVisibility, setRequestedOrientation, setResult, setResult, setSecondaryProgress, setShowWhenLocked, setTaskDescription, setTheme, setTitle, setTitle, setTitleColor, setTurnScreenOn, setVisible, setVolumeControlStream, setVrModeEnabled, shouldShowRequestPermissionRationale, shouldUpRecreateTask, showAssist, showDialog, showDialog, showLockTaskEscapeMessage, startActionMode, startActionMode, startActivities, startActivities, startActivity, startActivity, startActivityForResult, startActivityForResult, startActivityFromChild, startActivityFromChild, startActivityFromFragment, startActivityFromFragment, startActivityIfNeeded, startActivityIfNeeded, startIntentSender, startIntentSender, startIntentSenderForResult, startIntentSenderForResult, startIntentSenderFromChild, startIntentSenderFromChild, startLocalVoiceInteraction, startLockTask, startManagingCursor, startNextMatchingActivity, startNextMatchingActivity, startPostponedEnterTransition, startSearch, stopLocalVoiceInteraction, stopLockTask, stopManagingCursor, takeKeyEvents, triggerSearch, unregisterForContextMenuMethods inherited from class android.view.ContextThemeWrapperapplyOverrideConfiguration, getAssets, getResources, getThemeMethods inherited from class android.content.ContextWrapperbindService, checkCallingOrSelfPermission, checkCallingOrSelfUriPermission, checkCallingPermission, checkCallingUriPermission, checkPermission, checkSelfPermission, checkUriPermission, checkUriPermission, clearWallpaper, createConfigurationContext, createContextForSplit, createDeviceProtectedStorageContext, createDisplayContext, createPackageContext, databaseList, deleteDatabase, deleteFile, deleteSharedPreferences, enforceCallingOrSelfPermission, enforceCallingOrSelfUriPermission, enforceCallingPermission, enforceCallingUriPermission, enforcePermission, enforceUriPermission, enforceUriPermission, fileList, getApplicationContext, getApplicationInfo, getBaseContext, getCacheDir, getClassLoader, getCodeCacheDir, getContentResolver, getDatabasePath, getDataDir, getDir, getExternalCacheDir, getExternalCacheDirs, getExternalFilesDir, getExternalFilesDirs, getExternalMediaDirs, getFilesDir, getFileStreamPath, getMainExecutor, getMainLooper, getNoBackupFilesDir, getObbDir, getObbDirs, getPackageCodePath, getPackageManager, getPackageName, getPackageResourcePath, getSharedPreferences, getSystemServiceName, getWallpaper, getWallpaperDesiredMinimumHeight, getWallpaperDesiredMinimumWidth, grantUriPermission, isDeviceProtectedStorage, isRestricted, moveDatabaseFrom, moveSharedPreferencesFrom, openFileInput, openFileOutput, openOrCreateDatabase, openOrCreateDatabase, peekWallpaper, registerReceiver, registerReceiver, registerReceiver, registerReceiver, removeStickyBroadcast, removeStickyBroadcastAsUser, revokeUriPermission, revokeUriPermission, sendBroadcast, sendBroadcast, sendBroadcastAsUser, sendBroadcastAsUser, sendOrderedBroadcast, sendOrderedBroadcast, sendOrderedBroadcastAsUser, sendStickyBroadcast, sendStickyBroadcastAsUser, sendStickyOrderedBroadcast, sendStickyOrderedBroadcastAsUser, setWallpaper, setWallpaper, startForegroundService, startInstrumentation, startService, stopService, unbindService, unregisterReceiverMethods inherited from class android.content.ContextgetColor, getColorStateList, getDrawable, getString, getString, getSystemService, getText, obtainStyledAttributes, obtainStyledAttributes, obtainStyledAttributes, obtainStyledAttributes, registerComponentCallbacks, unregisterComponentCallbacksMethods inherited from class java.lang.Objectclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface android.view.Window.CallbackonPointerCaptureChanged
- 
Field Details- 
logger
- 
appClassThe application class to start
- 
appThe jme3 application object
- 
eglBitsPerPixelprotected int eglBitsPerPixelSets the desired RGB size for the surfaceview. 16 = RGB565, 24 = RGB888. (default = 24)
- 
eglAlphaBitsprotected int eglAlphaBitsSets the desired number of Alpha bits for the surfaceview. This affects how the surfaceview is able to display Android views that are located under the surfaceview jME uses to render the scenegraph. 0 = Opaque surfaceview background (fastest) 1->7 = Transparent surfaceview background 8 or higher = Translucent surfaceview background (default = 0)
- 
eglDepthBitsprotected int eglDepthBitsThe number of depth bits specifies the precision of the depth buffer. (default = 16)
- 
eglSamplesprotected int eglSamplesSets the number of samples to use for multisampling.
 Leave 0 (default) to disable multisampling.
 Set to 2 or 4 to enable multisampling.
- 
eglStencilBitsprotected int eglStencilBitsSet the number of stencil bits. (default = 0)
- 
frameRateprotected int frameRateSet the desired frame rate. If frameRate higher than 0, the application will be capped at the desired frame rate. (default = -1, no frame rate cap)
- 
audioRendererTypeSets the type of Audio Renderer to be used.Android MediaPlayer / SoundPool can be used on all supported Android platform versions (2.2+) 
 OpenAL Soft uses an OpenSL backend and is only supported on Android versions 2.3+.Only use ANDROID_ static strings found in AppSettings 
- 
joystickEventsEnabledprotected boolean joystickEventsEnabledIf true Android Sensors are used as simulated Joysticks. Users can use the Android sensor feedback through the RawInputListener or by registering JoyAxisTriggers.
- 
keyEventsEnabledprotected boolean keyEventsEnabledIf true KeyEvents are generated from TouchEvents
- 
mouseEventsEnabledprotected boolean mouseEventsEnabledIf true MouseEvents are generated from TouchEvents
- 
mouseEventsInvertXprotected boolean mouseEventsInvertXFlip X axis
- 
mouseEventsInvertYprotected boolean mouseEventsInvertYFlip Y axis
- 
finishOnAppStopprotected boolean finishOnAppStopif true finish this activity when the jme app is stopped
- 
handleExitHookprotected boolean handleExitHookset to false if you don't want the harness to handle the exit hook
- 
exitDialogTitleTitle of the exit dialog, default is "Do you want to exit?"
- 
exitDialogMessageMessage of the exit dialog, default is "Use your home key to bring this app into the background or exit to terminate it."
- 
screenFullScreenprotected boolean screenFullScreenSet 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.
- 
screenShowTitleprotected boolean screenShowTitleif screenShowTitle is true while screenFullScreen is false, then the title bar is also displayed under the notification bar
- 
splashPicIDprotected int splashPicIDSplash 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.
- 
ctx
- 
viewprotected android.opengl.GLSurfaceView view
- 
isGLThreadPausedprotected boolean isGLThreadPaused
- 
splashImageViewprotected android.widget.ImageView splashImageView
- 
frameLayoutprotected android.widget.FrameLayout frameLayout
 
- 
- 
Constructor Details- 
AndroidHarnesspublic AndroidHarness()
 
- 
- 
Method Details- 
onRetainNonConfigurationInstance- Overrides:
- onRetainNonConfigurationInstancein class- android.app.Activity
 
- 
onCreatepublic void onCreate(android.os.Bundle savedInstanceState) - Overrides:
- onCreatein class- android.app.Activity
 
- 
onRestartprotected void onRestart()- Overrides:
- onRestartin class- android.app.Activity
 
- 
onStartprotected void onStart()- Overrides:
- onStartin class- android.app.Activity
 
- 
onResumeprotected void onResume()- Overrides:
- onResumein class- android.app.Activity
 
- 
onPauseprotected void onPause()- Overrides:
- onPausein class- android.app.Activity
 
- 
onStopprotected void onStop()- Overrides:
- onStopin class- android.app.Activity
 
- 
onDestroyprotected void onDestroy()- Overrides:
- onDestroyin class- android.app.Activity
 
- 
getJmeApplication
- 
handleErrorCalled 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:
- handleErrorin interface- SystemListener
- Parameters:
- errorMsg- The error message, if any, or null.
- t- Throwable object, or null.
 
- 
onClickpublic void onClick(android.content.DialogInterface dialog, int whichButton) Called by the android alert dialog, terminate the activity and OpenGL rendering- Specified by:
- onClickin interface- android.content.DialogInterface.OnClickListener
- Parameters:
- dialog- ignored
- whichButton- the button index
 
- 
onTouchGets called by the InputManager on all touch/drag/scale events- Specified by:
- onTouchin interface- TouchListener
- Parameters:
- name- the name of the event
- evt- the touch event
- tpf- how much time has passed since the last frame
 
- 
layoutDisplaypublic void layoutDisplay()
- 
removeSplashScreenpublic void removeSplashScreen()
- 
initializeLogHandlerprotected void initializeLogHandler()Removes the standard Android log handler due to an issue with not logging entries lower than INFO level and adds a handler that produces JME formatted log messages.
- 
initializepublic void initialize()Description copied from interface:SystemListenerCallback 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:
- initializein interface- SystemListener
 
- 
reshapepublic void reshape(int width, int height) Description copied from interface:SystemListenerCalled to notify the application that the resolution has changed.- Specified by:
- reshapein interface- SystemListener
- Parameters:
- width- the new width of the display (in pixels, ≥0)
- height- the new height of the display (in pixels, ≥0)
 
- 
rescalepublic void rescale(float x, float y) Description copied from interface:SystemListenerCalled to notify the application that the scale has changed.- Specified by:
- rescalein interface- SystemListener
- Parameters:
- x- the new horizontal scale of the display
- y- the new vertical scale of the display
 
- 
updatepublic void update()Description copied from interface:SystemListenerCallback to update the application state, and render the scene to the back buffer.- Specified by:
- updatein interface- SystemListener
 
- 
requestClosepublic void requestClose(boolean esc) Description copied from interface:SystemListenerCalled 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 shut down the process from the task manager, or presses ESC.- Specified by:
- requestClosein interface- SystemListener
- Parameters:
- esc- If true, the user pressed ESC to close the application.
 
- 
destroypublic void destroy()Description copied from interface:SystemListenerCallback 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:
- destroyin interface- SystemListener
 
- 
gainFocuspublic void gainFocus()Description copied from interface:SystemListenerCalled 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:
- gainFocusin interface- SystemListener
 
- 
loseFocuspublic void loseFocus()Description copied from interface:SystemListenerCalled 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:
- loseFocusin interface- SystemListener
 
 
-