Java tutorial
/* * Copyright (C) 2016 Christian DeTamble * * This file is part of Voracious Viper. * * Voracious Viper is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * Voracious Viper is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with Voracious Viper. If not, see <http://www.gnu.org/licenses/>. */ package net.bplaced.therefactory.voraciousviper; import android.content.pm.PackageManager; import android.os.Bundle; import android.os.Handler; import android.os.Looper; import android.widget.Toast; import com.badlogic.gdx.backends.android.AndroidApplication; import com.badlogic.gdx.backends.android.AndroidApplicationConfiguration; import net.bplaced.therefactory.voraciousviper.constants.Config; import net.bplaced.therefactory.voraciousviper.misc.IAndroidInterface; public class AndroidLauncher extends AndroidApplication implements IAndroidInterface { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); AndroidApplicationConfiguration config = new AndroidApplicationConfiguration(); config.useAccelerometer = false; config.useCompass = false; config.useGyroscope = false; config.useWakelock = true; config.hideStatusBar = true; config.useImmersiveMode = true; initialize(new VoraciousViper(this), config); } @Override public void toast(final String message, final boolean longDuration) { Handler h = new Handler(Looper.getMainLooper()); h.post(new Runnable() { @Override public void run() { Toast.makeText(getApplicationContext(), message, longDuration ? Toast.LENGTH_LONG : Toast.LENGTH_SHORT).show(); } }); } @Override public String getVersionName() { try { return getPackageManager().getPackageInfo(getPackageName(), 0).versionName; } catch (PackageManager.NameNotFoundException e) { e.printStackTrace(); } return Config.GAME_VERSION_NAME; } @Override public int getVersionCode() { try { return getPackageManager().getPackageInfo(getPackageName(), 0).versionCode; } catch (PackageManager.NameNotFoundException e) { e.printStackTrace(); } return Config.GAME_VERSION_CODE; } }