0

according to this website https://github.com/libgdx/libgdx/wiki/Admob-in-libgdx

I know how to add a admob banner in a libgdx game through robovm, and that worked!

Everything works fine when my Iphone is connected to either wifi or grps. However when I turn off wifi and grps, the game would quit immediately after the splash screen. This is because the initializeAds function is not connected to either wifi or gprs.

In OBJC there is a file named connection.h to check whether gprs or wifi is connected. After that, we can initialize admob banner according to the status.

Is there a way to check connection status by robovm or is there a way to avoid the crash?

Thanks!

John J Smith
  • 11,435
  • 9
  • 53
  • 72

1 Answers1

0

Just write simple function on Java, which will ping google.com and return true/false. Use this to send the request:

Gdx.net.sendHttpRequest(HttpRequest httpRequest, HttpResponseListener httpResponseListener);

Than check in you httpResponseListener if you got the respond (there is internet connection) if it will have the error (there is not).

P.S For Android add this to manifest:

<uses-permission android:name="android.permission.INTERNET" />
Alon Zilberman
  • 2,120
  • 1
  • 16
  • 16