Actuators
- Introduction
- Android phones can buzz, beep, and burp.
- Vibration
- Get a Vibrator as a system service.
- Add permission to use it, in the manifest
<uses-permission android:name="android.permission.VIBRATE"/>
- Use the vibrate method to make it buzz.
Pass in an array of longs. The first value is the delay in ms before
turning the vibrator on, and the subsequent pairs of values are
times in ms to have the vibrator on and off.
- The pattern can be repeated using the next parameter, or -1 for no
repetition.
- Tones
- Create a ToneGenerator, setting the output stream and
volume.
- Use the startTone method to play one of the predefined
tones (for a specified length of time, for indefinite tones).
- Use the release method to release resources when finished.
- Example
MainActivity.java
activity_main.xml
strings.xml
AndroidManifest.xml