Google Play Game Services and LibGDX, how to integrate without displaying the title bar?

Connect successfully using this code:

Tutorial for adding Google Play services to LibGDX

However, now I see the android title bar visible. I tried to nail what exactly makes the title bar show (and I use verbatim code from the tutorial).

I think it has a MainActivity constructor in the mix, one way or another, it bypasses the LibGDX calls that noTitle requests.

So, I tried to add the NoTitleBar theme function to my manifest, and it works, but somehow, I now have orientation changes (which is not what the manifest says)

Can anyone see what I need to do in my Main or Android project so that

1) there is no title bar 2) do not allow orientation changes 3) connect to Google Play services.

Here is the manifest:

<?xml version="1.0" encoding="utf-8"?> <manifest xmlns:android="http://schemas.android.com/apk/res/android" package="pgs.libgdx.liars.dice" android:versionCode="1" android:versionName="1.0" > <uses-sdk android:minSdkVersion="5" android:targetSdkVersion="17" /> <application android:icon="@drawable/ic_launcher" android:label="@string/app_name" > <meta-data android:name="com.google.android.gms.games.APP_ID" android:value="@string/app_id" /> <activity android:name=".MainActivity" android:label="@string/app_name" android:theme="@android:style/Theme.NoTitleBar.Fullscreen" > android:screenOrientation="landscape" android:configChanges="keyboard|keyboardHidden|orientation|screenSize"> <intent-filter> <action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.LAUNCHER" /> </intent-filter> </activity> </application> </manifest> 

Here is the relevant code from Android Project:

 public class MainActivity extends AndroidApplication implements GameHelperListener, GoogleInterface { private GameHelper aHelper; private OnLeaderboardScoresLoadedListener theLeaderboardListener; public MainActivity(){ aHelper = new GameHelper(this); aHelper.enableDebugLog(true, "MYTAG"); //create a listener for getting raw data back from leaderboard theLeaderboardListener = new OnLeaderboardScoresLoadedListener() { public void onLeaderboardScoresLoaded(int arg0, LeaderboardBuffer arg1, LeaderboardScoreBuffer arg2) { System.out.println("In call back"); for(int i = 0; i < arg2.getCount(); i++){ System.out.println(arg2.get(i).getScoreHolderDisplayName() + " : " + arg2.get(i).getDisplayScore()); } } }; } @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); AndroidApplicationConfiguration cfg = new AndroidApplicationConfiguration(); cfg.useGL20 = false; aHelper.setup(this); initialize(new LiarsDiceGame(this), cfg); } 

and the main relevant code:

 public LiarsDiceGame(){ } public LiarsDiceGame(GoogleInterface anInterface ) { platformInterface = anInterface; //platformInterface.Login(); } @Override public void create() { float w = Gdx.graphics.getWidth(); float h = Gdx.graphics.getHeight(); camera = new OrthographicCamera(1, h/w); batch = new SpriteBatch(); texture = new Texture(Gdx.files.internal("data/libgdx.png")); texture.setFilter(TextureFilter.Linear, TextureFilter.Linear); TextureRegion region = new TextureRegion(texture, 0, 0, 512, 275); sprite = new Sprite(region); sprite.setSize(0.9f, 0.9f * sprite.getHeight() / sprite.getWidth()); sprite.setOrigin(sprite.getWidth()/2, sprite.getHeight()/2); sprite.setPosition(-sprite.getWidth()/2, -sprite.getHeight()/2); } 

Everything else is exactly the same as when setting up a LibGDX project using gdx-setup-ui.jar

+4
source share
1 answer

There is a problem with this line in the syntax of your manifest file:

 android:theme="@android:style/Theme.NoTitleBar.Fullscreen" > 

The angle bracket at the end of the line should not be there.

+4
source

Source: https://habr.com/ru/post/1494184/


All Articles