Esempio n. 1
0
 private void acquireWakeLock(final WakeLockOptions pWakeLockOptions) {
   if (pWakeLockOptions == WakeLockOptions.SCREEN_ON) {
     ActivityUtils.keepScreenOn(this);
   } else {
     final PowerManager pm = (PowerManager) this.getSystemService(Context.POWER_SERVICE);
     this.mWakeLock =
         pm.newWakeLock(pWakeLockOptions.getFlag() | PowerManager.ON_AFTER_RELEASE, "AndEngine");
     try {
       this.mWakeLock.acquire();
     } catch (final SecurityException e) {
       Debug.e(
           "You have to add\n\t<uses-permission android:name=\"android.permission.WAKE_LOCK\"/>\nto your AndroidManifest.xml !",
           e);
     }
   }
 }
Esempio n. 2
0
  private void applyEngineOptions(final EngineOptions pEngineOptions) {
    if (pEngineOptions.isFullscreen()) {
      ActivityUtils.requestFullscreen(this);
    }

    if (pEngineOptions.needsMusic() || pEngineOptions.needsSound()) {
      this.setVolumeControlStream(AudioManager.STREAM_MUSIC);
    }

    switch (pEngineOptions.getScreenOrientation()) {
      case LANDSCAPE:
        this.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
        break;
      case PORTRAIT:
        this.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
        break;
    }
  }