Android: Showing wrong screen resolution

前端 未结 6 1027
说谎
说谎 2020-11-29 10:19

I was trying to get the screen resolution of android phones,using this code

    DisplayMetrics dm = new DisplayMetrics();
    getWindowManager().getDefaultDi         


        
6条回答
  •  时光取名叫无心
    2020-11-29 10:56

    Finally after 2 days of searching and testing, i finally managed to find out what's the real issue here.. All those above coding will give correct resolution. But the most important this is that we need to mention the target SDK in the manifest file.. Otherwise it will give wrong result if the density is more than 1.

    
    

    need to set the targetSDK version from anything between 4-9.. Hope this will help some one in future facing the same issue.

提交回复
热议问题