List of usage examples for com.badlogic.gdx.backends.android AndroidNet AndroidNet
public AndroidNet(AndroidApplicationBase app)
From source file:org.gearvrf.plugins.widget.GVRWidgetPluginActivity.java
License:Apache License
private void init(ApplicationListener listener, AndroidApplicationConfiguration config, boolean isForView, EGLContext sharedcontext) {/*from w ww . jav a 2 s . com*/ // if (this.getVersion() < MINIMUM_SDK) { // throw new GdxRuntimeException("LibGDX requires Android API Level " + // MINIMUM_SDK + " or later."); // } mGraphics = new AndroidGraphics(this, config, config.resolutionStrategy == null ? new FillResolutionStrategy() : config.resolutionStrategy, sharedcontext); mInputDispatcher.setInput(AndroidInputFactory.newAndroidInput(this, this, mGraphics.getView(), config)); mAudio = new AndroidAudio(this, config); this.getFilesDir(); // workaround for Android bug #10515463 mFiles = new AndroidFiles(this.getAssets(), this.getFilesDir().getAbsolutePath()); mNet = new AndroidNet(this); this.mListener = listener; this.mHandler = new Handler(); this.mUseImmersiveMode = config.useImmersiveMode; this.mHideStatusBar = config.hideStatusBar; // Add a specialized audio lifecycle listener addLifecycleListener(new LifecycleListener() { @Override public void resume() { // No need to resume audio here } @Override public void pause() { mAudio.pause(); } @Override public void dispose() { mAudio.dispose(); } }); Gdx.app = this; Gdx.input = this.getInput(); Gdx.audio = this.getAudio(); Gdx.files = this.getFiles(); Gdx.graphics = this.getGraphics(); Gdx.net = this.getNet(); if (!isForView) { try { requestWindowFeature(Window.FEATURE_NO_TITLE); } catch (Exception ex) { log("AndroidApplication", "Content already displayed, cannot request FEATURE_NO_TITLE", ex); } getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN); getWindow().clearFlags(WindowManager.LayoutParams.FLAG_FORCE_NOT_FULLSCREEN); setContentView(mGraphics.getView(), createLayoutParams()); } createWakeLock(config.useWakelock); hideStatusBar(this.mHideStatusBar); useImmersiveMode(this.mUseImmersiveMode); if (this.mUseImmersiveMode && getVersion() >= Build.VERSION_CODES.KITKAT) { try { Class<?> vlistener = Class.forName("com.badlogic.gdx.backends.android.AndroidVisibilityListener"); Object o = vlistener.newInstance(); Method method = vlistener.getDeclaredMethod("createListener", AndroidApplicationBase.class); method.invoke(o, this); } catch (Exception e) { log("AndroidApplication", "Failed to create AndroidVisibilityListener", e); } } }