This site is in read only mode. Please continue to browse, but replying, likes, and other actions are disabled for now.
7 / 7
Jul 2018

Hi all
is there any way to get the device DPI values
without running shell ADB commands ?

  • created

    Jul '18
  • last reply

    Jul '18
  • 6

    replies

  • 405

    views

  • 3

    users

  • 2

    links

thanks
Any idea about how to get that info from IOS?

An Alternative:
I have some code that does a comparison between WebView pixels and Native View pixels… I am not absolutely sure this gets you hardware DPI but, in my experience using it, I think it does (I would appreciate someone correcting me if I am wrong)

Java:

AppiumDriver appDriver = <something passed into the method... can be AndroidDriver or IOSDriver at runtime>

 Set<String> contextNames = ((AppiumDriver) appDriver).getContextHandles();
        for (String contextName : contextNames) {

            if (contextName.contains("NATIVE")) {
                ((AppiumDriver<MobileElement>) appDriver).context(contextName);
            }
        }

double screenWidth = appDriver.manage().window().getSize().getWidth();
double screenHeight = appDriver.manage().window().getSize().getHeight();

Good Luck!

thanks
what you need to do if you want to access it from you JAVA code
is to get it from SessionDetails obj in case of IOS and from device caps in case of Android

10x