psv
psv

Reputation: 3287

Android test if haptic feedback is available

I have seen this question : check phone settings for haptic feedback but I don't understand the solution (for me it does not work).

Is there another solution ? I did not find anything on the javadoc.. ?

Thanks

Upvotes: 0

Views: 1951

Answers (1)

sergej shafarenka
sergej shafarenka

Reputation: 20416

You can add this method to any of your classes and use it to check whether haptic feedback is enabled.

public static boolean isHapticFeedbackEnabled(Context context) {
    int enabled = Settings.System.getInt(context.getContentResolver(),
        android.provider.Settings.System.HAPTIC_FEEDBACK_ENABLED, 0);
    return enabled != 0;
}

The method goes into system settings database and checks value of "haptic_feedback_enabled" setting. If there is 0 then haptic feedback is disables, otherwise it is enabled.

Upvotes: 6

Related Questions