How to get Device DPI

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

UIAutomator2 driver stores such information in capabilities along with some other useful device info

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

Try getSession endpoint: https://github.com/appium/appium-xcuitest-driver/blob/15e03c8061c0d3411f7566e334a24548a191b87d/lib/driver.js#L1025

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

Good to know. Thanks!