diff --git a/android/src/main/AndroidManifest.xml b/android/src/main/AndroidManifest.xml index 298475f14..c162fa2cb 100644 --- a/android/src/main/AndroidManifest.xml +++ b/android/src/main/AndroidManifest.xml @@ -25,14 +25,18 @@ android:backupAgent=".AndroidBackupHandler"> <activity android:label="${appName}" - android:name=".AndroidGame" - android:screenOrientation="nosensor" - android:configChanges="keyboard|keyboardHidden|orientation"> + android:name=".AndroidLauncher"> <intent-filter > <action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.LAUNCHER" /> </intent-filter> </activity> + <activity + android:label="${appName}" + android:name=".AndroidGame" + android:screenOrientation="nosensor" + android:configChanges="keyboard|keyboardHidden|orientation"> + </activity> </application> diff --git a/android/src/main/java/com/shatteredpixel/shatteredpixeldungeon/android/AndroidLauncher.java b/android/src/main/java/com/shatteredpixel/shatteredpixeldungeon/android/AndroidLauncher.java new file mode 100644 index 000000000..e8f62e5c6 --- /dev/null +++ b/android/src/main/java/com/shatteredpixel/shatteredpixeldungeon/android/AndroidLauncher.java @@ -0,0 +1,63 @@ +/* + * Pixel Dungeon + * Copyright (C) 2012-2015 Oleg Dolya + * + * Shattered Pixel Dungeon + * Copyright (C) 2014-2019 Evan Debenham + * + * This program 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. + * + * This program 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 this program. If not, see <http://www.gnu.org/licenses/> + */ + +package com.shatteredpixel.shatteredpixeldungeon.android; + +import android.annotation.SuppressLint; +import android.app.Activity; +import android.content.Intent; +import android.graphics.Typeface; +import android.os.Bundle; +import android.view.Gravity; +import android.widget.TextView; + +import com.badlogic.gdx.graphics.g2d.freetype.FreeType; +import com.badlogic.gdx.utils.GdxNativesLoader; + +public class AndroidLauncher extends Activity { + + @SuppressLint("SetTextI18n") + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + + try { + GdxNativesLoader.load(); + FreeType.initFreeType(); + + Intent intent = new Intent(this, AndroidGame.class); + startActivity(intent); + finish(); + } catch (Exception e){ + TextView text = new TextView(this); + text.setText("Shattered Pixel Dungeon cannot start because some of its code is missing!\n\n" + + "This usually happens when the Google Play version of the game is installed from somewhere outside of Google Play.\n\n" + + "If you're unsure of how to fix this, please email the developer (Evan@ShatteredPixel.com), and include this error message:\n\n" + + e.getMessage()); + text.setTextSize(16); + text.setTextColor(0xFFFFFFFF); + text.setTypeface(Typeface.createFromAsset(getAssets(), "pixel_font.ttf")); + text.setGravity(Gravity.CENTER_VERTICAL); + text.setPadding(10, 10, 10, 10); + setContentView(text); + } + } +}