P4A - AndroidVibrationModule
An Android Library that offers a mechanism for easily adding vibration feedback to Android applications.
The source code contains two main directories:
-
P4A_AndroidVibrationModule(link is external): This includes the source code of the P4A_AndroidVibrationModule
-
MyTestApp(link is external): This includes the source code of a sample application that uses the P4A_AndroidVibrationModule
Main features
The main features of the P4A AndroidVibrationModule include the following:
- A set of predefined vibration patterns(link is external)
- Vibration feedback when different events are fired: ON_CLICK(link is external), ON_LONG_CLICK(link is external), ON_FOCUS_CHANGE(link is external), ON_KEY(link is external), ON_TOUCH(link is external), ON_MENU_ITEM_CLICK(link is external), ON_CREATE_CONTEXT_MENU(link is external), ON_DRAG(link is external)
- Offering various functions for starting vibration(link is external), stoping vibration(link is external), examining if device supports vibration(link is external), etc.
Usage instructions
A complete example showing how the P4A AndroidVibrationModule can be used to add vibration vibration feedback to various GUI components of an Android application can be found here(link is external).
Adding haptic feedback in a GUI component (e.g. button, etc.) can be achieved using the P4A AndroidVibrationModule by a simple line of code:
P4A_VibrationModule.getInstance(this).addVibrationFeedbackOnEventListener(P4A_VibrationModule.ON_CLICK, findViewById(R.id.button1), 2000);
The example above adds vibration feedback to "button1". In particular, when this button is clicked, it vibrates for 2 seconds.
Further examples can be found here(link is external).
Funding Acknowledgement
The research leading to these results has received funding from the European Union's Seventh Framework Programme (FP7) under grant agreement No.610510