List of usage examples for com.badlogic.gdx.backends.android.surfaceview FillResolutionStrategy FillResolutionStrategy
FillResolutionStrategy
From source file:com.badlogic.gdx.backends.android.CardBoardAndroidApplication.java
License:Apache License
private void init(ApplicationListener listener, AndroidApplicationConfiguration config, boolean isForView) { if (this.getVersion() < MINIMUM_SDK) { throw new GdxRuntimeException("LibGDX requires Android API Level " + MINIMUM_SDK + " or later."); }/*w ww . j a v a2 s . co m*/ graphics = new CardBoardGraphics(this, config, config.resolutionStrategy == null ? new FillResolutionStrategy() : config.resolutionStrategy); input = AndroidInputFactory.newAndroidInput(this, this, graphics.view, config); audio = new AndroidAudio(this, config); this.getFilesDir(); // workaround for Android bug #10515463 files = new AndroidFiles(this.getAssets(), this.getFilesDir().getAbsolutePath()); net = new AndroidNet(this); this.listener = listener; this.handler = new Handler(); this.useImmersiveMode = config.useImmersiveMode; this.hideStatusBar = 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() { audio.pause(); } @Override public void dispose() { audio.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(graphics.getView(), createLayoutParams()); setCardboardView((CardboardView) graphics.getView()); } createWakeLock(config.useWakelock); hideStatusBar(this.hideStatusBar); useImmersiveMode(this.useImmersiveMode); if (this.useImmersiveMode && 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); } } }
From source file:de.cachebox_test.main.java
License:Open Source License
/** * Called when the activity is first created. *//*ww w . j ava 2 s. c o m*/ @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); GL.resetIsInitial(); if (GlobalCore.RunFromSplash) { Log.info(log, "CACHEBOX: " + "main-OnCreate Run from Splash"); } else { Log.info(log, "CACHEBOX: " + "main-OnCreate illegal-Run"); // run splash Intent mainIntent = new Intent().setClass(main.this, de.cachebox_test.splash.class); startActivity(mainIntent); finish(); return; } mainActivity = this; if (savedInstanceState != null) { // restore ACB after Kill Log.debug(log, "restore ACB after Kill"); GlobalCore.restartAfterKill = true; GlobalCore.isTab = savedInstanceState.getBoolean("isTab"); GlobalCore.useSmallSkin = savedInstanceState.getBoolean("useSmallSkin"); String workPath = savedInstanceState.getString("WorkPath"); // Read Config Config.Initialize(workPath, workPath + "/cachebox.config"); // hier muss die Config Db initialisiert werden Database.Settings = new AndroidDB(DatabaseType.Settings, this); if (!FileIO.createDirectory(Config.mWorkPath + "/User")) return; Database.Settings.StartUp(Config.mWorkPath + "/User/Config.db3"); // initialize Database Database.Data = new AndroidDB(DatabaseType.CacheBox, this); Database.FieldNotes = new AndroidDB(DatabaseType.FieldNotes, this); Config.AcceptChanges(); Resources res = this.getResources(); DevicesSizes ui = new DevicesSizes(); ui.Window = new Size(savedInstanceState.getInt("WindowWidth"), savedInstanceState.getInt("WindowHeight")); ui.Density = res.getDisplayMetrics().density; ui.isLandscape = false; new UiSizes(); UI_Size_Base.that.initial(ui); Global.Paints.init(this); Global.InitIcons(this); GlobalCore.restartCache = savedInstanceState.getString("selectedCacheID"); GlobalCore.restartWaypoint = savedInstanceState.getString("selectedWayPoint"); } else { GlobalCore.restartAfterKill = false; } ActivityUtils.onActivityCreateSetTheme(this); requestWindowFeature(Window.FEATURE_NO_TITLE); if (GlobalCore.isTab) { setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE); } else { setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT); } // initialize receiver for screen switched on/off IntentFilter filter = new IntentFilter(Intent.ACTION_SCREEN_ON); filter.addAction(Intent.ACTION_SCREEN_OFF); if (mReceiver == null) { mReceiver = new ScreenReceiver(); registerReceiver(mReceiver, filter); } // N = Config.nightMode.getValue(); setContentView(GlobalCore.isTab ? R.layout.tab_main : R.layout.main); findViewsById(); initialPlatformConector(); inflater = (LayoutInflater) this.getSystemService(Context.LAYOUT_INFLATER_SERVICE); mainActivity.setVolumeControlStream(AudioManager.STREAM_MUSIC); // create new splash splash sp = new splash(0, 0, UI_Size_Base.that.getWindowWidth(), UI_Size_Base.that.getWindowHeight(), "Splash"); // create new mainView TabMainView ma = new TabMainView(0, 0, UI_Size_Base.that.getWindowWidth(), UI_Size_Base.that.getWindowHeight(), "mainView"); glListener = new GL(UI_Size_Base.that.getWindowWidth(), UI_Size_Base.that.getWindowHeight(), sp, ma); int Time = Config.ScreenLock.getValue(); counter = new ScreenLockTimer(Time, Time); counter.start(); // add Event Handler SelectedCacheEventList.Add(this); CacheListChangedEventList.Add(this); // GpsStateChangeEventList.Add(this); vibrator = (Vibrator) getSystemService(Context.VIBRATOR_SERVICE); mSensorManager = (SensorManager) getSystemService(Context.SENSOR_SERVICE); mSensor = mSensorManager.getDefaultSensor(Sensor.TYPE_ORIENTATION); Config.AcceptChanges(); AndroidSettings.RunOverLockScreen.addChangedEventListener(new IChanged() { @Override public void isChanged() { setLockScreenProperty(); } }); // Initial Android TexturePacker new Android_Packer(); initialLocationManager(); initalMicIcon(); glListener.onStart(); if (tabFrame != null) tabFrame.setVisibility(View.INVISIBLE); if (frame != null) frame.setVisibility(View.INVISIBLE); InfoDownSlider.invalidate(); CacheListChangedEvent(); try { this.registerReceiver(this.mBatInfoReceiver, new IntentFilter(Intent.ACTION_BATTERY_CHANGED)); } catch (Exception e) { // sometimes: // ERROR/ActivityThread(15416): Activity de.cachebox_test.main has // leaked IntentReceiver // de.cachebox_test.main$7@4745a0f0 that was originally registered // here. // Are you missing a call to unregisterReceiver()? } downSlider.isInitial = false; int sollHeight = (Config.quickButtonShow.getValue() && Config.quickButtonLastShow.getValue()) ? UiSizes.that.getQuickButtonListHeight() : 0; setQuickButtonHeight(sollHeight); if (isFirstStart) { // ask for API key only if Rev-Number changed, like at new // installation and API Key is Empty if (Config.newInstall.getValue() && Config.GetAccessToken().equals("")) { askToGetApiKey(); } else { if (!GlobalCore.restartAfterKill) chkGpsIsOn(); } if (Config.newInstall.getValue()) { // wait for Copy Asset is closed CheckTranslationIsLoaded(); Timer tim = new Timer(); TimerTask timTask = new TimerTask() { @Override public void run() { mainActivity.runOnUiThread(new Runnable() { @Override public void run() { String Welcome = ""; String LangId = getString(R.string.langId); try { Welcome = Translation.GetTextFile("welcome", LangId); Welcome += Translation.GetTextFile("changelog", LangId); } catch (IOException e1) { e1.printStackTrace(); } MessageBox.Show(Welcome, Translation.Get("welcome"), MessageBoxIcon.None); } }); } }; tim.schedule(timTask, 5000); } if (input == null) { graphics = new AndroidGraphics(this, gdxConfig, gdxConfig.resolutionStrategy == null ? new FillResolutionStrategy() : gdxConfig.resolutionStrategy); input = new AndroidInput(this, this.inflater.getContext(), graphics.getView(), gdxConfig); } } if (aktView != null) ((View) aktView).setVisibility(View.INVISIBLE); if (aktTabView != null) ((View) aktTabView).setVisibility(View.INVISIBLE); if (InfoDownSlider != null) ((View) InfoDownSlider).setVisibility(View.INVISIBLE); if (cacheNameView != null) ((View) cacheNameView).setVisibility(View.INVISIBLE); initialViewGL(); }
From source file:de.cachebox_test.main.java
License:Open Source License
@Override protected void onPause() { Log.info(log, "Main=> onPause"); stopped = true;/*from www . j a v a2 s. com*/ unbindPluginServices(); if (input == null) { graphics = new AndroidGraphics(this, gdxConfig, gdxConfig.resolutionStrategy == null ? new FillResolutionStrategy() : gdxConfig.resolutionStrategy); input = new AndroidInput(this, this.inflater.getContext(), graphics.getView(), gdxConfig); } if (isFinishing()) { if (mConnection != null) { unbindService(mConnection); mConnection = null; } } super.onPause(); Log.debug(log, "Main=> onPause release SuppressPowerSaving"); try { if (this.mWakeLock != null) this.mWakeLock.release(); } catch (Exception e) { // dann ebend nicht! } }
From source file:de.cachebox_test.main.java
License:Open Source License
@Override protected void onResume() { viewGL.RenderContinous();//from w ww . j a v a 2 s . c o m if (stopped) { showWaitToRenderStartet(); invalidateTextureEventList.Call(); } Log.debug(log, "Main=> onResume"); if (input == null) { Log.debug(log, "Main=> onResume input== null"); graphics = new AndroidGraphics(this, gdxConfig, gdxConfig.resolutionStrategy == null ? new FillResolutionStrategy() : gdxConfig.resolutionStrategy); input = new AndroidInput(this, this.inflater.getContext(), graphics.getView(), gdxConfig); } super.onResume(); if (counter != null) { if (runsWithAkku) { counter.start(); } else { counter.cancel(); } } if (mSensorManager != null) mSensorManager.registerListener(mListener, mSensor, SensorManager.SENSOR_DELAY_UI); this.registerReceiver(this.mBatInfoReceiver, new IntentFilter(Intent.ACTION_BATTERY_CHANGED)); int sollHeight = (Config.quickButtonShow.getValue() && Config.quickButtonLastShow.getValue()) ? UiSizes.that.getQuickButtonListHeight() : 0; ((main) main.mainActivity).setQuickButtonHeight(sollHeight); downSlider.isInitial = false; InfoDownSlider.invalidate(); // Ausschalten verhindern /* * This code together with the one in onDestroy() will make the screen * be always on until this Activity gets destroyed. */ if (Config.SuppressPowerSaving.getValue()) { Log.debug(log, "Main=> onResume SuppressPowerSaving"); final PowerManager pm = (PowerManager) getSystemService(Context.POWER_SERVICE); int flags = PowerManager.SCREEN_BRIGHT_WAKE_LOCK; this.mWakeLock = pm.newWakeLock(flags, "Cachebox"); this.mWakeLock.acquire(); } Config.SuppressPowerSaving.addChangedEventListener(new IChanged() { @Override public void isChanged() { if (Config.SuppressPowerSaving.getValue()) { Log.debug(log, "Main=> onResume SuppressPowerSaving"); final PowerManager pm = (PowerManager) getSystemService(Context.POWER_SERVICE); int flags = PowerManager.SCREEN_BRIGHT_WAKE_LOCK; main.this.mWakeLock = pm.newWakeLock(flags, "Cachebox"); main.this.mWakeLock.acquire(); } else { final PowerManager pm = (PowerManager) getSystemService(Context.POWER_SERVICE); main.this.mWakeLock = pm.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, "Cachebox non Powersave"); main.this.mWakeLock.acquire(); } } }); try { initialOnTouchListener(); } catch (Exception e) { Log.err(log, "onResume", "initialOnTouchListener", e); } // Initial PlugIn fillPluginList(); bindPluginServices(); final Bundle extras = getIntent().getExtras(); if (!GlobalCore.restartAfterKill || extras != null) { ExtSearch_GcCode = extras.getString("GcCode"); ExtSearch_GpxPath = extras.getString("GpxPath"); if (ExtSearch_GpxPath != null) Log.info(log, "GPX found: " + ExtSearch_GpxPath); if (ExtSearch_GcCode != null || ExtSearch_GpxPath != null) { mustRunSearch = true; // ACB running call search if (TabMainView.that.isInitial()) { PlatformConnector.FirstShow(); } } // delete handled extras getIntent().removeExtra("GcCode"); getIntent().removeExtra("GpxPath"); } GL.that.RestartRender(); }
From source file:org.artoolkit.ar.base.ARActivity.java
License:Open Source License
@Override protected void onStart() { super.onStart(); Log.i(TAG, "Activity starting."); if (ARToolKit.getInstance().initialiseNativeWithOptions(this.getCacheDir().getAbsolutePath(), pattSize, pattCountMax) == false) { // Use cache directory for Data files. new AlertDialog.Builder(this) .setMessage("The native library is not loaded. The application cannot continue.") .setTitle("Error").setCancelable(true) .setNeutralButton(android.R.string.cancel, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { finish();//from www.j ava 2s. co m } }).show(); return; } mainLayout = supplyFrameLayout(); if (mainLayout == null) { Log.e(TAG, "Error: supplyFrameLayout did not return a layout."); return; } renderer = supplyRenderer(); if (renderer == null) { Log.e(TAG, "Error: supplyRenderer did not return a renderer."); // No renderer supplied, use default, which does nothing renderer = new ARRenderer(this, config, (config.resolutionStrategy == null) ? new FillResolutionStrategy() : config.resolutionStrategy); } }
From source file:org.gearvrf.plugins.widget.GVRWidgetPluginActivity.java
License:Apache License
private void init(ApplicationListener listener, AndroidApplicationConfiguration config, boolean isForView, EGLContext sharedcontext) {//from ww w . j a v a2 s . c om // 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); } } }