Take the 2-minute tour ×
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

I'm using LibGDX and flixel-android to build a Desktop/Android game. It feels like there should be a way of checking to see if you're currently being run on an Android device, the Desktop, and so on, but I can't find it anywhere. Am I supposed to just pass it down from the individual launchers? Surely LibGDX can just tell me?

share|improve this question

2 Answers 2

up vote 17 down vote accepted

I think you're after Application querying

switch(Gdx.app.getType()) {
   case ApplicationType.Android:
       // android specific code
   case ApplicationType.Desktop:
       // desktop specific code
   case ApplicationType.WebGl:
       /// HTML5 specific code
}
share|improve this answer
2  
Oh you star. That's absolutely what I wanted, I couldn't phrase it right for Google. Thanks! –  mtrc Sep 14 '12 at 11:30
4  
For reference: this has been changed to Gdx.app.getType() –  Amplify91 Sep 21 '12 at 18:45
1  
@Amplify91 Thank you! Your information is what I'm looking for! –  DatVM Feb 7 '13 at 7:13

Magd's code may have worked at one stage, it didn't with my version of GDX, or certainly not my implementation anyway. I had to change it as follows:

switch(Gdx.app.getType()) {
       case Android:
           // android specific code
           TouchPadController.createTouchPad();
       case Desktop:
           // desktop specific code
       case WebGL:
           /// HTML5 specific code

}

share|improve this answer
    
What version is this? The latest nightly? –  ThorinII Nov 1 '13 at 12:09

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.