Besides the changes mentioned previously, Android Marshmallow 6.0 has introduced a few more changes to the Bluetooth API.
Stylus has been here a for a while; Bluetooth stylus didn't have full support for specifications in versions before Android Marshmallow. You can pair and connect a compatible Bluetooth stylus with either a phone or a tablet. Because you are not bound just to touches on screen, you can fuse the position, pressure, and button state data, allowing more precise user input and experience. Your app can add a listener to the stylus buttons and act accordingly. Just use the View.OnContextClickListener
and GestureDetector.OnContextClickListener
objects in your activity.
In order to detect stylus button interactions and movement, you need the following:
The
MotionEvent
methodsThe
getTooltype()
method, which returnsTOOL_TYPE_STYLUS
if a stylus with a button is touched on the screenThe
getButtonState()
method, which returns (on Android...