Package com.jme3.app
Class AndroidHarnessFragment
- java.lang.Object
-
- android.app.Fragment
-
- com.jme3.app.AndroidHarnessFragment
-
- All Implemented Interfaces:
android.content.ComponentCallbacks,android.content.ComponentCallbacks2,android.content.DialogInterface.OnClickListener,android.view.View.OnCreateContextMenuListener,android.view.View.OnLayoutChangeListener,com.jme3.input.controls.InputListener,com.jme3.input.controls.TouchListener,com.jme3.system.SystemListener
public class AndroidHarnessFragment extends android.app.Fragment implements com.jme3.input.controls.TouchListener, android.content.DialogInterface.OnClickListener, android.view.View.OnLayoutChangeListener, com.jme3.system.SystemListener- Author:
- iwgeric
-
-
Field Summary
Fields Modifier and Type Field Description protected java.lang.StringappClassThe application class to startprotected java.lang.StringaudioRendererTypeSets the type of Audio Renderer to be used.protected integlAlphaBitsSets the desired number of Alpha bits for the surfaceview.protected integlBitsPerPixelSets the desired RGB size for the surfaceview.protected integlDepthBitsThe number of depth bits specifies the precision of the depth buffer.protected integlSamplesSets the number of samples to use for multisampling.
Leave 0 (default) to disable multisampling.
Set to 2 or 4 to enable multisampling.protected integlStencilBitsSet the number of stencil bits.protected java.lang.StringexitDialogMessageMessage 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.StringexitDialogTitleTitle of the exit dialog, default is "Do you want to exit?"protected booleanfinishOnAppStopif true finish this activity when the jme app is stoppedprotected android.widget.FrameLayoutframeLayoutprotected intframeRateSet the desired frame rate.protected booleanhandleExitHookset to false if you don't want the harness to handle the exit hookprotected booleanjoystickEventsEnabledIf true Android Sensors are used as simulated Joysticks.protected booleankeyEventsEnabledIf true KeyEvents are generated from TouchEventsprotected intmaxResolutionDimensionSet the maximum resolution for the surfaceview in either the width or height screen direction depending on the screen size.protected booleanmouseEventsEnabledIf true MouseEvents are generated from TouchEventsprotected booleanmouseEventsInvertXFlip X axisprotected booleanmouseEventsInvertYFlip Y axisprotected android.widget.ImageViewsplashImageViewprotected intsplashPicIDSplash Screen picture Resource ID.protected android.opengl.GLSurfaceViewview
-
Constructor Summary
Constructors Constructor Description AndroidHarnessFragment()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidcreateLayout()voiddestroy()voidgainFocus()com.jme3.app.ApplicationgetJmeApplication()voidhandleError(java.lang.String errorMsg, java.lang.Throwable t)Called when an error has occurred.voidinitialize()protected voidinitializeLogHandler()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.voidloseFocus()voidonActivityCreated(android.os.Bundle savedInstanceState)voidonAttach(android.app.Activity activity)voidonClick(android.content.DialogInterface dialog, int whichButton)Called by the android alert dialog, terminate the activity and OpenGL renderingvoidonCreate(android.os.Bundle savedInstanceState)This Fragment uses setRetainInstance(true) so the onCreate method will only be called once.android.view.ViewonCreateView(android.view.LayoutInflater inflater, android.view.ViewGroup container, android.os.Bundle savedInstanceState)Called by the system to create the View hierarchy associated with this Fragment.voidonDestroy()Called by the system when the application is being destroyed.voidonDestroyView()Called by the Android system each time the Activity is destroyed or recreated.voidonDetach()voidonLayoutChange(android.view.View v, int left, int top, int right, int bottom, int oldLeft, int oldTop, int oldRight, int oldBottom)voidonPause()When the Fragment pauses (i.e.voidonResume()When the Fragment resumes (i.e.voidonStart()voidonStop()voidonTouch(java.lang.String name, com.jme3.input.event.TouchEvent evt, float tpf)Gets called by the InputManager on all touch/drag/scale eventsvoidremoveSplashScreen()voidrequestClose(boolean esc)voidrescale(float x, float y)voidreshape(int width, int height)voidupdate()-
Methods inherited from class android.app.Fragment
dump, equals, getActivity, getAllowEnterTransitionOverlap, getAllowReturnTransitionOverlap, getArguments, getChildFragmentManager, getContext, getEnterTransition, getExitTransition, getFragmentManager, getHost, getId, getLayoutInflater, getLoaderManager, getParentFragment, getReenterTransition, getResources, getRetainInstance, getReturnTransition, getSharedElementEnterTransition, getSharedElementReturnTransition, getString, getString, getTag, getTargetFragment, getTargetRequestCode, getText, getUserVisibleHint, getView, hashCode, instantiate, instantiate, isAdded, isDetached, isHidden, isInLayout, isRemoving, isResumed, isStateSaved, isVisible, onActivityResult, onAttach, onAttachFragment, onConfigurationChanged, onContextItemSelected, onCreateAnimator, onCreateContextMenu, onCreateOptionsMenu, onDestroyOptionsMenu, onGetLayoutInflater, onHiddenChanged, onInflate, onInflate, onInflate, onLowMemory, onMultiWindowModeChanged, onMultiWindowModeChanged, onOptionsItemSelected, onOptionsMenuClosed, onPictureInPictureModeChanged, onPictureInPictureModeChanged, onPrepareOptionsMenu, onRequestPermissionsResult, onSaveInstanceState, onTrimMemory, onViewCreated, onViewStateRestored, postponeEnterTransition, registerForContextMenu, requestPermissions, setAllowEnterTransitionOverlap, setAllowReturnTransitionOverlap, setArguments, setEnterSharedElementCallback, setEnterTransition, setExitSharedElementCallback, setExitTransition, setHasOptionsMenu, setInitialSavedState, setMenuVisibility, setReenterTransition, setRetainInstance, setReturnTransition, setSharedElementEnterTransition, setSharedElementReturnTransition, setTargetFragment, setUserVisibleHint, shouldShowRequestPermissionRationale, startActivity, startActivity, startActivityForResult, startActivityForResult, startIntentSenderForResult, startPostponedEnterTransition, toString, unregisterForContextMenu
-
-
-
-
Field Detail
-
appClass
protected java.lang.String appClass
The application class to start
-
eglBitsPerPixel
protected int eglBitsPerPixel
Sets the desired RGB size for the surfaceview. 16 = RGB565, 24 = RGB888. (default = 24)
-
eglAlphaBits
protected int eglAlphaBits
Sets 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)
-
eglDepthBits
protected int eglDepthBits
The number of depth bits specifies the precision of the depth buffer. (default = 16)
-
eglSamples
protected int eglSamples
Sets the number of samples to use for multisampling.
Leave 0 (default) to disable multisampling.
Set to 2 or 4 to enable multisampling.
-
eglStencilBits
protected int eglStencilBits
Set the number of stencil bits. (default = 0)
-
frameRate
protected int frameRate
Set 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)
-
maxResolutionDimension
protected int maxResolutionDimension
Set the maximum resolution for the surfaceview in either the width or height screen direction depending on the screen size. If the surfaceview is rectangular, the longest side (width or height) will have the resolution set to a maximum of maxResolutionDimension. The other direction will be set to a value that maintains the aspect ratio of the surfaceview.
Any value less than 0 (default = -1) will result in the surfaceview having the same resolution as the view layout (i.e. no max resolution).
-
audioRendererType
protected java.lang.String audioRendererType
Sets 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
-
joystickEventsEnabled
protected boolean joystickEventsEnabled
If true Android Sensors are used as simulated Joysticks. Users can use the Android sensor feedback through the RawInputListener or by registering JoyAxisTriggers.
-
keyEventsEnabled
protected boolean keyEventsEnabled
If true KeyEvents are generated from TouchEvents
-
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."
-
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.
-
frameLayout
protected android.widget.FrameLayout frameLayout
-
view
protected android.opengl.GLSurfaceView view
-
splashImageView
protected android.widget.ImageView splashImageView
-
-
Method Detail
-
getJmeApplication
public com.jme3.app.Application getJmeApplication()
-
onAttach
public void onAttach(android.app.Activity activity)
- Overrides:
onAttachin classandroid.app.Fragment
-
onCreate
public void onCreate(android.os.Bundle savedInstanceState)
This Fragment uses setRetainInstance(true) so the onCreate method will only be called once. During device configuration changes, the instance of this Fragment will be reused in the new Activity. This method should not contain any View related objects. They are created and destroyed by other methods. View related objects should not be reused, but rather created and destroyed along with the Activity.- Overrides:
onCreatein classandroid.app.Fragment- Parameters:
savedInstanceState- the saved instance state
-
onCreateView
public android.view.View onCreateView(android.view.LayoutInflater inflater, android.view.ViewGroup container, android.os.Bundle savedInstanceState)Called by the system to create the View hierarchy associated with this Fragment. For jME, this is a FrameLayout that contains the GLSurfaceView and an overlaying SplashScreen Image (if used). The View that is returned will be placed on the screen within the boundaries of the View borders defined by the Activity's layout parameters for this Fragment. For jME, we also update the application reference to the new view.- Overrides:
onCreateViewin classandroid.app.Fragment- Parameters:
inflater- ignoredcontainer- ignoredsavedInstanceState- ignored- Returns:
- the new view
-
onActivityCreated
public void onActivityCreated(android.os.Bundle savedInstanceState)
- Overrides:
onActivityCreatedin classandroid.app.Fragment
-
onStart
public void onStart()
- Overrides:
onStartin classandroid.app.Fragment
-
onResume
public void onResume()
When the Fragment resumes (i.e. after app resumes or device screen turned back on), call the gainFocus() in the jME application.- Overrides:
onResumein classandroid.app.Fragment
-
onPause
public void onPause()
When the Fragment pauses (i.e. after home button pressed on the device or device screen turned off) , call the loseFocus() in the jME application.- Overrides:
onPausein classandroid.app.Fragment
-
onStop
public void onStop()
- Overrides:
onStopin classandroid.app.Fragment
-
onDestroyView
public void onDestroyView()
Called by the Android system each time the Activity is destroyed or recreated. For jME, we clear references to the GLSurfaceView.- Overrides:
onDestroyViewin classandroid.app.Fragment
-
onDestroy
public void onDestroy()
Called by the system when the application is being destroyed. In this case, the jME application is actually closed as well. This method is not called during device configuration changes or when the application is put in the background.- Overrides:
onDestroyin classandroid.app.Fragment
-
onDetach
public void onDetach()
- Overrides:
onDetachin classandroid.app.Fragment
-
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:
handleErrorin interfacecom.jme3.system.SystemListener
-
onClick
public void onClick(android.content.DialogInterface dialog, int whichButton)Called by the android alert dialog, terminate the activity and OpenGL rendering- Specified by:
onClickin interfaceandroid.content.DialogInterface.OnClickListener- Parameters:
dialog- ignoredwhichButton- the button index
-
onTouch
public void onTouch(java.lang.String name, com.jme3.input.event.TouchEvent evt, float tpf)Gets called by the InputManager on all touch/drag/scale events- Specified by:
onTouchin interfacecom.jme3.input.controls.TouchListener
-
createLayout
public void createLayout()
-
removeSplashScreen
public void removeSplashScreen()
-
initializeLogHandler
protected 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.
-
initialize
public void initialize()
- Specified by:
initializein interfacecom.jme3.system.SystemListener
-
reshape
public void reshape(int width, int height)- Specified by:
reshapein interfacecom.jme3.system.SystemListener
-
rescale
public void rescale(float x, float y)- Specified by:
rescalein interfacecom.jme3.system.SystemListener
-
update
public void update()
- Specified by:
updatein interfacecom.jme3.system.SystemListener
-
requestClose
public void requestClose(boolean esc)
- Specified by:
requestClosein interfacecom.jme3.system.SystemListener
-
destroy
public void destroy()
- Specified by:
destroyin interfacecom.jme3.system.SystemListener
-
gainFocus
public void gainFocus()
- Specified by:
gainFocusin interfacecom.jme3.system.SystemListener
-
loseFocus
public void loseFocus()
- Specified by:
loseFocusin interfacecom.jme3.system.SystemListener
-
onLayoutChange
public void onLayoutChange(android.view.View v, int left, int top, int right, int bottom, int oldLeft, int oldTop, int oldRight, int oldBottom)- Specified by:
onLayoutChangein interfaceandroid.view.View.OnLayoutChangeListener
-
-