Appafly
Appafly

Reputation: 666

How to detect if the device is an Amazon kindle in libgdx

I want to do something if the device that is running my libgdx app is an Amazon kindle. How do I detect this. I found how to do not using libgdx using android.os.Build.MANUFACTURER, but it doesn't work in a libgdx game. So how do I detect if the device is an Amazon kindle in libgdx?

Thanks in advance!

Upvotes: 1

Views: 96

Answers (1)

ditzel
ditzel

Reputation: 136

Add two constructors and attributes to your core project class:

public String model;
public String manufacturer;

public MyGame(){ }                                //for web, ios and desktop
public MyGame(String manufacturer, String model){ //for android
    this.manufacturer = manufacturer;
    this.model = model;
}

In the AndroidLauncher of your android project you can pass the values Build.MANUFACTURER and Build.MODEL to your class constructor:

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    AndroidApplicationConfiguration config = new AndroidApplicationConfiguration();
    initialize(new MyGame(Build.MANUFACTURER,Build.MODEL), config);
}

You can have a look in the device specifications of amazon with value belongs to the kindle.

Upvotes: 1

Related Questions