@Override
    public EGLConfig chooseConfig(EGL10 egl, EGLDisplay display) {
        logger.fine("GLSurfaceView asking for egl config");
        Config requestedConfig = getRequestedConfig();
        EGLConfig[] configs = getConfigs(egl, display);

        // First try to find an exact match, but allowing a higher stencil
        EGLConfig chosenConfig = chooseConfig(egl, display, configs, requestedConfig, false, false, false, true);
        if (chosenConfig == null && requestedConfig.d > 16) {
            logger.log(Level.INFO, "EGL configuration not found, reducing depth");
            requestedConfig.d = 16;
            chosenConfig = chooseConfig(egl, display, configs, requestedConfig, false, false, false, true);
        }

        if (chosenConfig == null) {
            logger.log(Level.INFO, "EGL configuration not found, allowing higher RGB");
            chosenConfig = chooseConfig(egl, display, configs, requestedConfig, true, false, false, true);
        }

        if (chosenConfig == null && requestedConfig.a > 0) {
            logger.log(Level.INFO, "EGL configuration not found, allowing higher alpha");
            chosenConfig = chooseConfig(egl, display, configs, requestedConfig, true, true, false, true);
        }

        if (chosenConfig == null && requestedConfig.s > 0) {
            logger.log(Level.INFO, "EGL configuration not found, allowing higher samples");
            chosenConfig = chooseConfig(egl, display, configs, requestedConfig, true, true, true, true);
        }

        if (chosenConfig == null && requestedConfig.a > 0) {
            logger.log(Level.INFO, "EGL configuration not found, reducing alpha");
            requestedConfig.a = 1;
            chosenConfig = chooseConfig(egl, display, configs, requestedConfig, true, true, false, true);
        }

        if (chosenConfig == null && requestedConfig.s > 0) {
            logger.log(Level.INFO, "EGL configuration not found, reducing samples");
            requestedConfig.s = 1;
            if (requestedConfig.a > 0) {
                chosenConfig = chooseConfig(egl, display, configs, requestedConfig, true, true, true, true);
            } else {
                chosenConfig = chooseConfig(egl, display, configs, requestedConfig, true, false, true, true);
            }
        }

        if (chosenConfig == null && requestedConfig.getBitsPerPixel() > 16) {
            logger.log(Level.INFO, "EGL configuration not found, setting to RGB565");
            requestedConfig.r = 5;
            requestedConfig.g = 6;
            requestedConfig.b = 5;
            chosenConfig = chooseConfig(egl, display, configs, requestedConfig, true, false, false, true);

            if (chosenConfig == null) {
                logger.log(Level.INFO, "EGL configuration not found, allowing higher alpha");
                chosenConfig = chooseConfig(egl, display, configs, requestedConfig, true, true, false, true);
            }
        }

        if (chosenConfig == null) {
            logger.log(Level.INFO, "EGL configuration not found, looking for best config with >= 16 bit Depth");
            // failsafe: pick the best config with depth >= 16
            requestedConfig = new Config(0, 0, 0, 0, 16, 0, 0);
            chosenConfig = chooseConfig(egl, display, configs, requestedConfig, true, false, false, true);
        }

        if (chosenConfig != null) {
            logger.fine("GLSurfaceView asks for egl config, returning: ");
            logEGLConfig(chosenConfig, display, egl, Level.FINE);

            storeSelectedConfig(egl, display, chosenConfig);
            return chosenConfig;
        } else {
            logger.severe("No EGL Config found");
            return null;
        }
    }
Gets called by the GLSurfaceView class to return the best config
jme3-android/src/main/java/com/jme3/system/android/AndroidConfigChooser.java