how to detect if the screen is capacitive or resis

2019-02-13 17:12发布

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

2条回答
别忘想泡老子
2楼-- · 2019-02-13 17:33

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 :(

查看更多
冷血范
3楼-- · 2019-02-13 17:52

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.

查看更多
登录 后发表回答