1

My android device has a Display Mode under Settings -> Display page. This display-mode settings screen displays various display modes such as 480i, 480p, 720p, 1080p, 1080i etc... My device has Android OS version 2.3.3. Please note, this is a custom made Android device.

When I select any of these display modes, my device's mode get changed. I need to get the currently selected display-mode value programatically.

Is there any way this can be done ?

The Settings screen The <code>Settings</code> screen

The Display Settings screen The <code>Display Settings</code> screen

The Output Mode spinner The <code>Output Mode</code> spinner

sunil
  • 6,444
  • 1
  • 32
  • 44
  • Such as this? http://stackoverflow.com/questions/1016896/android-how-to-get-screen-dimensions – QVDev Sep 26 '12 at 10:11
  • May you can use the density to get what you want: http://stackoverflow.com/questions/3166501/getting-the-screen-density-programmatically-in-android – Bruno Bieri Sep 26 '12 at 10:33
  • @QVDev that post deals with screen dimensions. what i need is the display mode set currently for the system. As this [wiki](http://en.wikipedia.org/wiki/480p) indicates, 480p itself can have several resolutions. So i may need to keep some tables to calculate the screen-mode. But this can be erroneous. Somewhere this settings must be stored in the system and it should be retrieved via some system properties. rt ? – sunil Sep 26 '12 at 11:26
  • @viperbone your link calculates the screen density. How can i get the display-mode from screen density ? – sunil Sep 26 '12 at 11:27
  • I can't see a Diplay Mode settig. Which version of Android do you use? Could you also post a screenshot of the setting? – Bruno Bieri Sep 26 '12 at 11:34
  • @viperbone i just added screenshots. plz have a look. thxs – sunil Sep 26 '12 at 12:14
  • @viperbone My device has OS version 2.3.3 in it. Please note this is a custom made android device – sunil Sep 27 '12 at 05:20

2 Answers2

1

I got a solution.

First way

I saw an app named About. This application lists SystemProperties as list with propertyname and value. From this, i got the required property name as ubootenv.var.outputmode.

Then i got another thread which reads the SystemProperties using the getprop android command from here : Parsing Android getprop

By this way, now i am able to get the display-output-mode parameter.

Second way

I also tried using android.os.SystemProperties class via reflection and tried invoking get method. But this is returning null always.

Anyway the first method is working. Thanks for your help :)

Community
  • 1
  • 1
sunil
  • 6,444
  • 1
  • 32
  • 44
  • Both "ubootenv.var.outputmode" and "display-output-mode" didn't get me anything. How did you get it? I've found some apps that somehow get the real, max display resolution, such as these : https://play.google.com/store/apps/details?id=ru.andr7e.deviceinfohw https://play.google.com/store/apps/details?id=com.drhowdydoo.displayinfo . I think they find all the display modes, but what I've found of the official API ( https://developer.android.com/reference/android/view/Display#getSupportedModes() ) doesn't seem to work like what they got. – android developer Feb 21 '23 at 07:41
-2
    Display display = getWindowManager().getDefaultDisplay();
    final Point size = new Point();

    try{
        display.getSize(size);
    }catch(NoSuchMethodError nsme){
        Log.w(TAG, "@ Error caz of display.getSize() : " + nsme);
        size.x = display.getWidth();
        size.y = display.getHeight();
    }

getSize() supports from API level 13. That's why we need to use a try catch block.

AnujAroshA
  • 4,623
  • 8
  • 56
  • 99