VibrationEffect.BasicEnvelopeBuilder Class

Definition

A builder for waveform effects defined by their envelope, designed to provide a consistent haptic perception across devices with varying capabilities.

[Android.Runtime.Register("android/os/VibrationEffect$BasicEnvelopeBuilder", ApiSince=36, DoNotGenerateAcw=true)]
public sealed class VibrationEffect.BasicEnvelopeBuilder : Java.Lang.Object
[<Android.Runtime.Register("android/os/VibrationEffect$BasicEnvelopeBuilder", ApiSince=36, DoNotGenerateAcw=true)>]
type VibrationEffect.BasicEnvelopeBuilder = class
    inherit Object
Inheritance
VibrationEffect.BasicEnvelopeBuilder
Attributes

Remarks

A builder for waveform effects defined by their envelope, designed to provide a consistent haptic perception across devices with varying capabilities.

This builder simplifies the creation of waveform effects by automatically adapting them to different devices based on their capabilities. Effects are defined by control points specifying target vibration intensity and sharpness, along with durations to reach those targets. The vibrator will smoothly transition between these control points.

<b>Intensity:</b> Defines the overall strength of the vibration, ranging from 0 (off) to 1 (maximum achievable strength). Higher values result in stronger vibrations. Supported intensity values guarantee sensitivity levels (SL) above 10 dB SL to ensure human perception.

<b>Sharpness:</b> Defines the crispness of the vibration, ranging from 0 to 1. Lower values produce smoother vibrations, while higher values create a sharper, more snappy sensation. Sharpness is mapped to its equivalent frequency within the device's supported frequency range.

While this builder handles most of the adaptation logic, it does come with some limitations: <ul> <li>It may not use the full range of frequencies</li> <li>It's restricted to a frequency range that can generate output of at least 10 db SL</li> <li>Effects must end with a zero intensity control point. Failure to end at a zero intensity control point will result in an IllegalStateException.</li> </ul>

The builder automatically starts all effects at 0 intensity.

To avoid these limitations and to have more control over the effects output, use WaveformEnvelopeBuilder, where direct amplitude and frequency values can be used.

For optimal cross-device consistency, it's recommended to limit the number of control points to a maximum of 16. However this is not mandatory, and if a pattern exceeds the maximum number of allowed control points, the framework will automatically break down the effect to ensure it plays correctly.

For example, the following code creates a vibration effect that ramps up the intensity from a low-pitched to a high-pitched strong vibration over 500ms and then ramps it down to 0 (off) over 100ms:

{@code
            VibrationEffect effect = new VibrationEffect.BasicEnvelopeBuilder()
                .setInitialSharpness(0.0f)
                .addControlPoint(1.0f, 1.0f, 500)
                .addControlPoint(0.0f, 1.0f, 100)
                .build();
            }

Java documentation for android.os.VibrationEffect.BasicEnvelopeBuilder.

Portions of this page are modifications based on work created and shared by the Android Open Source Project and used according to terms described in the Creative Commons 2.5 Attribution License.

Constructors

Name Description
VibrationEffect.BasicEnvelopeBuilder()

Initializes a new instance of the VibrationEffect.BasicEnvelopeBuilder class.

Properties

Name Description
Class

Returns the runtime class of this Object.

(Inherited from Object)
Handle

The handle to the underlying Android instance.

(Inherited from Object)
JniIdentityHashCode

Gets the identity hash code assigned to this Java peer by the interop runtime.

(Inherited from Object)
JniPeerMembers

Provides JNI peer-member metadata for this type.

PeerReference

Gets the JNI object reference for this Java peer.

(Inherited from Object)
ThresholdClass

This API supports the Mono for Android infrastructure and is not intended to be used directly from your code.

(Inherited from Object)
ThresholdType

This API supports the Mono for Android infrastructure and is not intended to be used directly from your code.

(Inherited from Object)

Methods

Name Description
AddControlPoint(Single, Single, Int64)

Adds a new control point to the end of this waveform envelope. Intensity defines the overall strength of the vibration, ranging from 0 (off) to 1 (maximum achievable strength).

Build()

Build the waveform as a single VibrationEffect . The BasicEnvelopeBuilder object is still valid after this call, so you can continue adding more primitives to it and generating more VibrationEffect s by calling this method again.

Clone()

Creates and returns a copy of this object.

(Inherited from Object)
Dispose()

Releases the resources held by this Java peer.

(Inherited from Object)
Dispose(Boolean)

Releases the resources held by this Java peer.

(Inherited from Object)
Equals(Object)

Indicates whether some other object is "equal to" this one.

(Inherited from Object)
GetHashCode()

Returns a hash code value for the object.

(Inherited from Object)
JavaFinalize()

Called by the garbage collector on an object when garbage collection determines that there are no more references to the object.

(Inherited from Object)
Notify()

Wakes up a single thread that is waiting on this object's monitor.

(Inherited from Object)
NotifyAll()

Wakes up all threads that are waiting on this object's monitor.

(Inherited from Object)
SetHandle(IntPtr, JniHandleOwnership)

Sets the Handle property.

(Inherited from Object)
SetInitialSharpness(Single)

Sets the initial sharpness for the basic envelope effect. The effect will start vibrating at this sharpness when it transitions to the intensity and sharpness defined by the first control point.

ToArray<T>()

Creates a managed array from this Java array wrapper.

(Inherited from Object)
ToString()

Returns a string representation of the object.

(Inherited from Object)
UnregisterFromRuntime()

Unregisters this Java peer from the interop runtime.

(Inherited from Object)
Wait()

Causes the current thread to wait until it is awakened, typically by being <em>notified</em> or <em>interrupted</em>.

(Inherited from Object)
Wait(Int64, Int32)

Causes the current thread to wait until it is awakened, typically by being <em>notified</em> or <em>interrupted</em>, or until a certain amount of real time has elapsed.

(Inherited from Object)
Wait(Int64)

Causes the current thread to wait until it is awakened, typically by being <em>notified</em> or <em>interrupted</em>, or until a certain amount of real time has elapsed.

(Inherited from Object)

Explicit Interface Implementations

Name Description
IJavaPeerable.Disposed()

Notifies the interop runtime that this managed peer has been disposed.

(Inherited from Object)
IJavaPeerable.DisposeUnlessReferenced()

Releases this Java peer unless it is retained by another managed reference.

(Inherited from Object)
IJavaPeerable.Finalized()

Notifies the interop runtime that this managed peer has been finalized.

(Inherited from Object)
IJavaPeerable.JniManagedPeerState

Gets the state that describes the relationship between this managed peer and its JNI reference.

(Inherited from Object)
IJavaPeerable.SetJniIdentityHashCode(Int32)

Sets the interop identity hash code for this Java peer.

(Inherited from Object)
IJavaPeerable.SetJniManagedPeerState(JniManagedPeerStates)

Sets the managed and JNI peer state for this Java peer.

(Inherited from Object)
IJavaPeerable.SetPeerReference(JniObjectReference)

Sets the JNI object reference used by this managed peer.

(Inherited from Object)

Extension Methods

Name Description
GetJniTypeName(IJavaPeerable)

Gets the JNI name of the type of the instance self.

JavaAs<TResult>(IJavaPeerable)

Try to coerce self to type TResult, checking that the coercion is valid on the Java side.

JavaCast<TResult>(IJavaObject)

Performs an Android runtime-checked type conversion.

JavaCast<TResult>(IJavaObject)
TryJavaCast<TResult>(IJavaPeerable, TResult)

Try to coerce self to type TResult, checking that the coercion is valid on the Java side.

Applies to