how to detect if the screen is capacitive or resistive in an Android device?

╄→尐↘猪︶ㄣ 提交于 2019-11-30 05:17:26

问题


I am developing an application that will behave slightly different depending on the type of screen. Is there any way to detect it?


回答1:


android.content.res.Configuration contains a value called touchscreen, which could be TOUCHSCREEN_STYLUS (=resistive), TOUCHSCREEN_FINGER (=capacitive), TOUCHSCREEN_NOTOUCH (=no touch screen), TOUCHSCREEN_UNDEFINED (=uh oh).

EDIT: I got Dianne'd again :) So - bottom line, it seems like there is no way to get the actual physical properties of the screen. I guess your best bet is to have a setting to allow users to switch between your two modes.




回答2:


I have a small trick to do it but requires a canvas. Just detecting in a motionEvent if

event.getPressure() > 0 then is capacitive ; event.getSize() > 0 then is resistive

the problem is I dont want to use a canvas just for detecting it :(



来源:https://stackoverflow.com/questions/4294754/how-to-detect-if-the-screen-is-capacitive-or-resistive-in-an-android-device

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!