@Override
    @SuppressWarnings("unchecked")
    public void onCreate(Bundle savedInstanceState) {
        initializeLogHandler();
        logger.fine("onCreate");
        super.onCreate(savedInstanceState);

        // Create Settings
        logger.log(Level.FINE, "Creating settings");
        AppSettings settings = new AppSettings(true);
        settings.setEmulateMouse(mouseEventsEnabled);
        settings.setEmulateMouseFlipAxis(mouseEventsInvertX, mouseEventsInvertY);
        settings.setUseJoysticks(joystickEventsEnabled);
        settings.setEmulateKeyboard(keyEventsEnabled);

        settings.setBitsPerPixel(eglBitsPerPixel);
        settings.setAlphaBits(eglAlphaBits);
        settings.setDepthBits(eglDepthBits);
        settings.setSamples(eglSamples);
        settings.setStencilBits(eglStencilBits);
        settings.setAudioRenderer(audioRendererType);

        settings.setFrameRate(frameRate);

        // Create application instance
        try {
            if (app == null) {
                Class clazz = Class.forName(appClass);
                app = (LegacyApplication) clazz.getDeclaredConstructor().newInstance();
            }

            app.setSettings(settings);
            app.start();
        } catch (Exception ex) {
            handleError("Class " + appClass + " init failed", ex);
        }

        OGLESContext ctx = (OGLESContext) app.getContext();
        // AndroidHarness wraps the app as a SystemListener.
        ctx.setSystemListener(this);

        setRetainInstance(true);
    }
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.

@param savedInstanceState the saved instance state
jme3-android/src/main/java/com/jme3/app/AndroidHarnessFragment.java