@Override
  public void onWindowFocusChanged(boolean hasFocus) {

    super.onWindowFocusChanged(hasFocus);

    if (hasFocus) {
      updateImmersiveMode();
    }
  }
  @Override
  public void onSurfaceChanged(GL10 gl, int width, int height) {
    super.onSurfaceChanged(gl, width, height);

    if (immersiveModeChanged) {
      requestedReset = true;
      immersiveModeChanged = false;
    }
  }
 @Override
 public void onPause() {
   super.onPause();
   try {
     if (Dungeon.hero != null) {
       Dungeon.saveAll();
     }
   } catch (IOException e) {
     // TODO Auto-generated catch block
     e.printStackTrace();
   }
 }
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    sharedpreferences = getSharedPreferences(MyPREFERENCES, Context.MODE_PRIVATE);
    SharedPreferences.Editor editor = sharedpreferences.edit();
    int countShowAds = sharedpreferences.getInt("countShowAds", 0);

    // String placeModFilesHere = "placeModFilesHere";

    PixelDungeon.moddingMode(false);
    ModdingMode.mode(PixelDungeon.moddingMode());
    /*
    if(!FileSystem.getExternalStorageFile(placeModFilesHere).exists()) {
    	try {
    		FileSystem.getExternalStorageFile(placeModFilesHere).createNewFile();
    	} catch (IOException e) {
    		GLog.i(e.getMessage());
    		e.printStackTrace();
    	}
    }
    */
    PixelDungeon.instance().initIap();

    if (PixelDungeon.uiLanguage().equals("ko")) {
      PixelDungeon.classicFont(false);
    }

    ModdingMode.setClassicTextRenderingMode(PixelDungeon.classicFont());

    useLocale(uiLanguage());

    updateImmersiveMode();

    DisplayMetrics metrics = new DisplayMetrics();
    instance().getWindowManager().getDefaultDisplay().getMetrics(metrics);
    boolean landscape = metrics.widthPixels > metrics.heightPixels;

    if (Preferences.INSTANCE.getBoolean(Preferences.KEY_LANDSCAPE, false) != landscape) {
      landscape(!landscape);
    }

    Music.INSTANCE.enable(music());
    Sample.INSTANCE.enable(soundFx());
    secondQuickslot();

    if (PixelDungeon.version() != Game.versionCode) {
      switchScene(WelcomeScene.class);
    }

    if (countShowAds >= 2) {
      final ConnectivityManager conMgr =
          (ConnectivityManager) getSystemService(Context.CONNECTIVITY_SERVICE);
      final NetworkInfo activeNetwork = conMgr.getActiveNetworkInfo();
      if (activeNetwork != null && activeNetwork.isConnected()) {
        Intent intent = new Intent(this, Ads.class);
        startActivity(intent);
      }
      editor.putInt("countShowAds", 0);
    } else {
      if (countShowAds == 0) {
        editor.putInt("countShowAds", 1);
      } else {
        editor.putInt("countShowAds", countShowAds + 1);
      }
    }
    editor.commit();
  }