0

For an internal android test application I want to make an application that either forces the device to render it using a specific resolution, or has a max dpi the device can use to display the app. I tried compiling it with different android sdks, setting the targetSdk to different versions and in my manifest I tried writing

It does not seem to be working. I know that forcing a screen resolution is bound to be bad practice in any mobile world, but this is only an app for internal use and it will never see any market. Is there a way to force a specific resolution? I know it is possible, at least to make the app run in a sort of compatibility mode. You can, using reflection, retrieve some information about the display metrics of a (or any in the app) view using View.getContext().getResources().getDisplayMetrics() to find the displayMetrics, and find the private fields widthPixels, noncompatWidthPixels, heightPixels and noncompatHeightPixels.

Thanks in advance

Jimmi Beanz
  • 11
  • 2
  • 3
  • Thats a kinda feature for iOS, not for android, unless you make a view which you can change size of and have everything in that. – FabianCook Feb 21 '14 at 09:31
  • I know it is possible to do in Android. Perhaps it is not a real change of resolution, but the screen is able to enter a mode where the rendering is scaled or something along those lines. – Jimmi Beanz Feb 21 '14 at 10:05
  • Targeting version 8 will make things appear like that. But not sure on scaling – FabianCook Feb 21 '14 at 10:07
  • Thanks! I tried targeting version 8, but with no success. Do you know what sdk I should compile with? – Jimmi Beanz Feb 21 '14 at 10:11
  • Any, its not about the SDK you use. Its about your code. As I said, you should have a view which is a container to your application, and then change the size of the view. – FabianCook Feb 21 '14 at 10:12
  • Thank you. How should I change the size of my view? – Jimmi Beanz Feb 21 '14 at 10:17
  • Create the view dynamically http://stackoverflow.com/questions/2963152/android-how-to-resize-a-custom-view-programmatically – FabianCook Feb 21 '14 at 10:18

1 Answers1

0
Display display = getWindowManager().getDefaultDisplay();
Point size = new Point();
display.getSize(size);
int width = size.x;
int height = size.y;

You can use this code to get the dimensions in oncreate of your mainactivity and check the dimensions suitting your needs and if not give user dialog that this app is not for you!!

Hope this helps.

Piyush
  • 18,895
  • 5
  • 32
  • 63
Pramod
  • 1,123
  • 2
  • 12
  • 33
  • Thank you for your reply! I unfortunately don't think it will help me. I know how to look-up the screen resolution, but now how to change it. I followed the guide on [android developer](http://developer.android.com/guide/practices/screen-compat-mode.html) but with no result. I don't care if it is a hacky solution or I have to compile with a very old android sdk. – Jimmi Beanz Feb 21 '14 at 09:55