Sound and Vibration Feedback
PUBLISHED
You can play sound and vibration feedback with a specific pattern.
The main features of the Tizen.System.Feedback
class are:
- Playing a specific feedback pattern
You can play a sound or vibrate with a specific pattern, or both. For a list of supported feedback patterns, see the Tizen.System.Feedback [1] class reference.
- Checking for pattern support
You can determine whether a specific pattern is supported for a given feedback type.
Prerequisites
To enable your application to use the feedback functionality:
- To use vibration feedback, the application has to request permission by adding the following privilege to the
tizen-manifest.xml
file:<privileges> <privilege>http://tizen.org/privilege/haptic</privilege> </privileges>
- To use the methods and properties of the
Tizen.System.Feedback
class, include the Tizen.System [2] namespace in your application:
using Tizen.System;
Playing Feedback with a Specific Type and Pattern
To play a specific feedback pattern with a specific feedback type:
- Create a new instance of the Tizen.System.Feedback [1] class:
Feedback feedback = new Feedback();
- Play the feedback with the
Play()
method of theTizen.System.Feedback
class. As parameters, enter the feedback type (defined by the Tizen.System.FeedbackType [3] enumeration), and a string to denote the pattern to be played:
feedback.Play(FeedbackType.Sound, "Tap");
- To stop the feedback, use the
Stop()
method:
feedback.Stop();
Checking for Pattern Support
To determine whether a specific pattern is supported for a specific feedback type, use the IsSupportedPattern()
method of the Tizen.System.Feedback [1] class:
bool support; Feedback feedback = new Feedback(); support = feedback.IsSupportedPattern(FeedbackType.Vibration, "Key0");
The return value defines whether the pattern is supported for the feedback type.