0

I'm currently developing an app that as usual has to run on multiple devices but there is one more special than the others. An Acer DA241HL which is a 24" "Tablet" with a 1920x1080px resolution that should be wall mounted somewhere.

Is there a good way to identify this screen. Right now it reacts to the values-sw600dp folder. But what ever changes I make for this enormous tablet shouldn't affect normal tablet which would happen if I change stuff in that folder.

The following code:

    DisplayMetrics metrics = getResources().getDisplayMetrics();
    float density  = getResources().getDisplayMetrics().density;
    float dpHeight = metrics.heightPixels / density;
    float dpWidth  = metrics.widthPixels / density;
    Log.e("screen", "******************************************************");
    Log.w("screen", "d " + density + " y" + dpHeight + " x" + dpWidth + " deviceType:" + getResources().getString(R.string.device_type));
    Log.e("screen", "******************************************************");

Print the following:

******************************************************
d 1.0 y1032.0 x1920.0 deviceType:5
******************************************************

But I dont see how I can make that useful. The other way I thought about is to get the model number of the device but that creates new problem if they decide to get a similar device but not the same.

Suggestions?

just_user
  • 11,769
  • 19
  • 90
  • 135

1 Answers1

1

Is there a good way to identify this screen

Use something like -swNNNdp, for a suitably high value of NNN.

Right now it reacts to the values-sw600dp folder

Well, sure, but that screen is far larger than 600dp in its smallest width.

But what ever changes I make for this enormous tablet shouldn't affect normal tablet which would happen if I change stuff in that folder.

Then add a res/values-sw1000dp/ directory, for resources to use for screens with 1000dp in the smallest width, which will include your Acer but will not include more normal-sized tablets.

CommonsWare
  • 986,068
  • 189
  • 2,389
  • 2,491
  • thanks for your answer! But as long as I have strings.xml in that folder (values-sw1000db) I get a crash with no logcat output. dimens.xml works. Any suggestions? – just_user Jul 31 '14 at 11:07
  • @just_user: "I get a crash with no logcat output" -- I find that difficult to believe. If you are crashing, you should be getting a stack trace in LogCat. I'm also not quite clear why your strings would be changing in this case. Without a stack trace or something more to go on, I don't really have any idea what may be going wrong. – CommonsWare Jul 31 '14 at 11:11
  • no idea why I dont get a stacktrace in the LogCat for that. Other crashes are all reported. But if I rename strings.xml in that folder to xstrings.xml it works. I keep one string there to identify the device type, phone, tablet and now huge-tablet to load content of menus dynamically. Thanks for your help! – just_user Jul 31 '14 at 11:18
  • @just_user: "But if I rename strings.xml in that folder to xstrings.xml it works" -- since the filename in `values` resource directories does not matter, this is very strange. – CommonsWare Jul 31 '14 at 11:21
  • Indeed. What makes it stranger is strings.xml in "values-sw600dp" has no troubles at all. – just_user Jul 31 '14 at 11:46