Disable vibration for a notification

After a long trial & error session, I think I finally understood what’s wrong. The problem lies in this instruction notificationBuilder.setDefaults(Notification.DEFAULT_ALL). No matter what parameter you pass to notificationBuilder.setVibrate() after setting DEFAULT_ALL or DEFAULT_VIBRATE will be silently discarded. Someone at Google must have decided to give a higher precedence to setDefaults than to setVibrate. This … Read more

How to enable haptic feedback on button view

UPDATE ON DECEMBER 24TH 2019: The view must be enabled Haptic function by: Add android:hapticFeedbackEnabled=”true” in xml. Or use view.setHapticFeedbackEnabled(true); in code (Cited from Ivan Chau) However, one more thing to take into consideration is to enable Haptic Setting in virtual devices. This is annoying sometimes, so we have some flags come to help (which … Read more

Are there APIs for custom vibrations in iOS?

After serval hours’ digging in the Contact App, I have figured out how it works. ABNewPersonViewControlle invoke some class in ToneLibrary framework to do this. The call stack looks like this: 0 CoreFoundation 0x3359a1d4 CFGetTypeID + 0 1 CoreFoundation 0x33596396 __CFPropertyListIsValidAux + 46 2 CoreFoundation 0x33517090 CFPropertyListCreateData + 124 3 AudioToolbox 0x38ac255a AudioServicesPlaySystemSoundWithVibration + 158 … Read more

How to make iPhone vibrate using Swift?

Short example: import UIKit import AudioToolbox class ViewController: UIViewController { override func viewDidLoad() { super.viewDidLoad() AudioServicesPlayAlertSound(SystemSoundID(kSystemSoundID_Vibrate)) } } load onto your phone and it will vibrate. You can put it in a function or IBAction as you wish. Code Update: AudioServicesPlayAlertSoundWithCompletion(SystemSoundID(kSystemSoundID_Vibrate)) { } As apple code docs written: This function will be deprecated in a … Read more

Making the iPhone vibrate

From “iPhone Tutorial: Better way to check capabilities of iOS devices”: There are two seemingly similar functions that take a parameter kSystemSoundID_Vibrate: 1) AudioServicesPlayAlertSound(kSystemSoundID_Vibrate); 2) AudioServicesPlaySystemSound(kSystemSoundID_Vibrate); Both of the functions vibrate the iPhone. But, when you use the first function on devices that don’t support vibration, it plays a beep sound. The second function, on … Read more

How to make an Android device vibrate? with different frequency?

Try: import android.os.Vibrator; … Vibrator v = (Vibrator) getSystemService(Context.VIBRATOR_SERVICE); // Vibrate for 500 milliseconds if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { v.vibrate(VibrationEffect.createOneShot(500, VibrationEffect.DEFAULT_AMPLITUDE)); } else { //deprecated in API 26 v.vibrate(500); } Note: Don’t forget to include permission in AndroidManifest.xml file: <uses-permission android:name=”android.permission.VIBRATE”/>

tech