Search code examples
androiddevicejunit4resolutionrobotium

Testing an Android device resolution using Robotium


Is there a way we can test an android device's resolution?


Solution

  • In any test function you can write following code:

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

    or if API<13

    Display display = getWindowManager().getDefaultDisplay(); 
    int width = display.getWidth(); 
    int height = display.getHeight();