java.lang.Object | |
↳ | com.android.phone.HapticFeedback |
Handles the haptic feedback: a light buzz happening when the user presses a soft key (UI button or capacitive key). The haptic feedback is controlled by: - a system resource for the pattern The pattern used is tuned per device and stored in an internal resource (config_virtualKeyVibePattern.) - a system setting HAPTIC_FEEDBACK_ENABLED. HAPTIC_FEEDBACK_ENABLED can be changed by the user using the system Settings activity. It must be rechecked each time the activity comes in the foreground (onResume). This class is not thread safe. It assumes it'll be called from the UI thead. Typical usage: -------------- static private final boolean HAPTIC_ENABLED = true; private HapticFeedback mHaptic = new HapticFeedback(); protected void onCreate(Bundle icicle) { mHaptic.init((Context)this, HAPTIC_ENABLED); } protected void onResume() { // Refresh the system setting. mHaptic.checkSystemSetting(); } public void foo() { mHaptic.vibrate(); }
Public Constructors | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Public Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Reload the system settings to check if the user enabled the
haptic feedback.
| |||||||||||
Initialize this instance using the app and system
configs.
| |||||||||||
Generate the haptic feedback vibration.
|
[Expand]
Inherited Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
From class
java.lang.Object
|
Reload the system settings to check if the user enabled the haptic feedback.
Initialize this instance using the app and system configs. Since these don't change, init is typically called once in 'onCreate'. checkSettings is not called during init.
context | To look up the resources and system settings. |
---|---|
enabled | If false, vibrate will be a no-op regardless of the system settings. |
Generate the haptic feedback vibration. Only one thread can request it. If the phone is already in a middle of an haptic feedback sequence, the request is ignored.