Friday, October 3, 2014

GETTING MONEY! AdMob and GPS implementation in android

Today Steven tried to use the Nuggetta framework to make cross-compiling work between iOS and Android SDKs. It would be ideal as we would just need to implement their facebook integration code directly into our core project. However it seemed like libGDX was not updated, their APIs and skeleton tutorials was linked to the old roboVM build of libGDX iOS. Which basically means that you have to do a lot of things manually anyway since you need to rewrite the parts that they haven't implemented yet. Something that Steven tried to put some time into, however quickly gave up as the documentation was lacking and it seemed like such a small community that there was no point in asking for help.

So instead Steven looked into what Axel did tried with BRI, something that turned out to be quite a hastle. I have not yet started on any iOS bindings, but I got adMob to work with android and succedded in implementing an ad on the top of the screen, using

import android.view.View;
import android.view.Window;
import android.view.WindowManager;
import android.widget.LinearLayout;
import android.widget.RelativeLayout;

import android.widget.RelativeLayout.LayoutParams;
import com.google.android.gms.ads.AdView;

All these nice libraries. The thing with ads is, you need to create different views, layers if you will. That is our RelativeLayout, we then create an adView (adView) and a gameView (View), these are added to our RelativeLayout and with a little of behind the scenes magic, we have two different views, one showing our ad, and one displaying our gameView.

The views are not layered by when they are added into the layout, it is not like a stack or a list. But by setting an ID to the view 

adView.setId(12345);

You can determine which view will be on top. I think higher IDs are on top!

So I do not even know if we are going to have ads in our game, but it is nice to know that just simple android code works in libgdx and that it is implementable. Now we just need to figure out how to change the state of the android application from within our core project code. (Notice: Just needs to...)



Here is a screenshot of what I got working, notice the ad at the top!

I also tried to click on the ad, and it worked!