Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to distinguish between mobile and desktop browser? #96

Closed
Quillraven opened this issue Apr 9, 2023 · 1 comment
Closed

How to distinguish between mobile and desktop browser? #96

Quillraven opened this issue Apr 9, 2023 · 1 comment

Comments

@Quillraven
Copy link

Hi,

I have a question: how do you distinguish between mobile and desktop browser?

I saw a code snippet like:

val userAgent = Window.Navigator.getUserAgent() ?: ""
if(userAgent.contains("Mobile") || userAgent.contains("Android")) {
  // mobile browser
}

but this does not seem to work because of missing GWTBridge class at runtime. Also, it is GWT stuff and I am not sure if this is the correct approach for TeaVM.

In LibGDX itself I only see an ApplicationType which always return WebGL for TeaVM backend. I think you cannot distinguish between mobile and desktop browser with that.

How would you solve that?

@xpenatan
Copy link
Owner

Hi. sorry for long delay. Very busy with work.

TeaWebAgent and TeaAgentInfo class check OS and browser. Maybe adding mobile and android will work.
https://github.com/xpenatan/gdx-teavm/blob/master/backends/backend-teavm/src/main/java/com/github/xpenatan/gdx/backends/teavm/agent/TeaWebAgent.java

It just set as a system property in TeaApplication.init(). I guess this part of code needs improvements.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants