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

后端 未结 2 2044
生来不讨喜
生来不讨喜 2021-01-05 18:02

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

相关标签:
2条回答
  • 2021-01-05 18:07

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

    0 讨论(0)
  • 2021-01-05 18:28

    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.

    0 讨论(0)
提交回复
热议问题