runtime determination of android model

Hi,

I’m looking for a way to, at run time, determine if I’m running on a Kindle Fire or not.

Why?  My screen is losing some data past 1040 due to Kindle Fire screen size.

Probably not the best way of solving my problem, but possibly the quickest for now :slight_smile:

There’s a single place in my code where I’d like to say:

   if device.type = “Kindle Fire” then 

     max_x = 1040;

Although there are probably better ways, I’m not yet comfortable with the whole scaling approach,

and I just need to get a copy of my app running on a Kindle Fire quickly, so I can use it during a 

performance on Thurdsay :slight_smile:

At present, I’m going to hard code the “yes, it’s a Kindle”, build, deploy, and then remove the line …

which is kludgey, but it works.

thanks,

Stan

System

here is where you want to start for working this out:

https://docs.coronalabs.com/api/library/system/getInfo.html

Scaling

Also, I strongly suggest you use a 640x960 or similar base resolution with letterbox scaling.

Once you understand how this works and settle on a single base resolution for all your designs, you will be happy and save a lot of effort. (https://docs.coronalabs.com/guide/basics/configSettings/index.html#contentscaling)

I know some folks like to write complex config.lua files, but honestly that has always caused me more trouble than it is worth.

In SSK2 (not beautiful code, but wonderful solutions to many common problems), I implement variables:

  • left, right, top, bottom - The edges of the current screen regardless of configuration
  • w, h - The values specified in config.lua
  • fullw, fullh, - The actual width and height (not pixels, but scaled w and h)
  • centerX, centerY - Just what they sound like.
  • unusedWidth, unusedHeight - Sometimes useful values that basically tell me if the device is wider or taller than my config.lua values and by how much.  Only one can have a non-zero value and sometimes both are 0.

Armed with this and a solid knowledge of the absolute maximum scaled widths, I can easily create single assets that are suitable in all cases.  As well I can choose to adjust to the changing width or go with a fixed layout.  I usually do the prior.

to detect Kindle devices you can use  store.target == "amazon"

@sgs is absolutely correct.  You must however be disciplined and remember to select the target when you build for this to work.

I forgot to mention too.  SSK detect many target types: https://roaminggamer.github.io/RGDocs/pages/SSK2/libraries/system/

(More detected than listed in docs which are getting out-of-date)

https://github.com/roaminggamer/SSK2/blob/master/ssk2/system.lua

@roaminggamer … thanks!  Very useful.  model = “KFFOWI” on my Kindle Fire 7".

@Sphere… thanks.  That would work for me short term, certainly.  In the medium term, it would perhaps mislead me

when I’m on newer/fancier Kindles with better resolution.  (Of course, so might checking for model KFFOWI :slight_smile:

thanks, all!

I think @sgs posted a better solution then re-posted…

In my thread history I see he said

Kindle devices all have the same device type of  Kxxxxx  so you can use that

This would match your findings.

@sieler2, seen as only Amazon builds work on Kindle devices my method is foolproof.  Kindles do not come with Google services pre-installed.

System

here is where you want to start for working this out:

https://docs.coronalabs.com/api/library/system/getInfo.html

Scaling

Also, I strongly suggest you use a 640x960 or similar base resolution with letterbox scaling.

Once you understand how this works and settle on a single base resolution for all your designs, you will be happy and save a lot of effort. (https://docs.coronalabs.com/guide/basics/configSettings/index.html#contentscaling)

I know some folks like to write complex config.lua files, but honestly that has always caused me more trouble than it is worth.

In SSK2 (not beautiful code, but wonderful solutions to many common problems), I implement variables:

  • left, right, top, bottom - The edges of the current screen regardless of configuration
  • w, h - The values specified in config.lua
  • fullw, fullh, - The actual width and height (not pixels, but scaled w and h)
  • centerX, centerY - Just what they sound like.
  • unusedWidth, unusedHeight - Sometimes useful values that basically tell me if the device is wider or taller than my config.lua values and by how much.  Only one can have a non-zero value and sometimes both are 0.

Armed with this and a solid knowledge of the absolute maximum scaled widths, I can easily create single assets that are suitable in all cases.  As well I can choose to adjust to the changing width or go with a fixed layout.  I usually do the prior.

to detect Kindle devices you can use  store.target == "amazon"

@sgs is absolutely correct.  You must however be disciplined and remember to select the target when you build for this to work.

I forgot to mention too.  SSK detect many target types: https://roaminggamer.github.io/RGDocs/pages/SSK2/libraries/system/

(More detected than listed in docs which are getting out-of-date)

https://github.com/roaminggamer/SSK2/blob/master/ssk2/system.lua

@roaminggamer … thanks!  Very useful.  model = “KFFOWI” on my Kindle Fire 7".

@Sphere… thanks.  That would work for me short term, certainly.  In the medium term, it would perhaps mislead me

when I’m on newer/fancier Kindles with better resolution.  (Of course, so might checking for model KFFOWI :slight_smile:

thanks, all!

I think @sgs posted a better solution then re-posted…

In my thread history I see he said

Kindle devices all have the same device type of  Kxxxxx  so you can use that

This would match your findings.

@sieler2, seen as only Amazon builds work on Kindle devices my method is foolproof.  Kindles do not come with Google services pre-installed.