2022年3月31日 星期四

Android Studio - 手機震動類(Vibrator Class)(八十一)

Android Studio - 手機震動類(Vibrator Class)(八十一):

當處於一個寧靜的環境,例如在劇院、圖書館、會議、教堂或嘈吵環境,手機便利用機內的震動功能作為提示,通知用戶,便可以避免錯過重要時刻。Android Studio 提共了手機震動類(Vibrator Class),可以程式震動功能,方便編程。

手機調成靜音模式標示
Summary:

Constants

Description

int

VIBRATION_EFFECT_SUPPORT_NO

Vibration effect support: unsupported - This effect is not natively supported by the underlying hardware, although the system may still play a fallback vibration. Constant Value: 2 (0x00000002)

int

VIBRATION_EFFECT_SUPPORT_UNKNOWN

Vibration effect support: unknown - The hardware doesn't report its supported effects, so we can't determine whether the effect is supported or not. Constant Value: 0 (0x00000000)

int

VIBRATION_EFFECT_SUPPORT_YES

Vibration effect support: supported - This effect is supported by the underlying hardware. Constant Value: 1 (0x00000001)


Public methods:

Public methods

Description

final int

areAllEffectsSupported(int... effectIds)

Query whether the vibrator supports all the given effects.

final boolean

areAllPrimitivesSupported(int... primitiveIds)

Query whether the vibrator supports all of the given primitives.

int[]

areEffectsSupported(int... effectIds)

Query whether the vibrator natively supports the given effects.

boolean[]

arePrimitivesSupported(int... primitiveIds)

Query whether the vibrator supports the given primitives.

abstract void

cancel()

Turn the vibrator off.

VibratorFrequencyProfile

getFrequencyProfile()

Gets the profile that describes the vibrator output across the supported frequency range.

int

getId()

Return the ID of this vibrator.

int[]

getPrimitiveDurations(int... primitiveIds)

Query the estimated durations of the given primitives.

float

getQFactor()

Gets the Q factor of the vibrator.

float

getResonantFrequency()

Gets the resonant frequency of the vibrator, if applicable.

abstract boolean

hasAmplitudeControl()

Check whether the vibrator has amplitude control.

boolean

hasFrequencyControl()

Check whether the vibrator has independent frequency control.

abstract boolean

hasVibrator()

Check whether the hardware has a vibrator.

void

vibrate(long milliseconds)

This method was deprecated in API level 26. Use vibrate(android.os.VibrationEffect) instead.

void

vibrate(VibrationEffect vibe, VibrationAttributes attributes)

Vibrate with a given effect.

void

vibrate(long[] pattern, int repeat)

This method was deprecated in API level 26. Use vibrate(android.os.VibrationEffect) instead.

void

vibrate(VibrationEffect vibe, AudioAttributes attributes)

This method was deprecated in API level Tiramisu. Use vibrate(android.os.VibrationEffect, android.os.VibrationAttributes) instead.

void

vibrate(long milliseconds, AudioAttributes attributes)

This method was deprecated in API level 26. Use vibrate(android.os.VibrationEffect, android.os.VibrationAttributes) instead.

void

vibrate(VibrationEffect vibe)

Vibrate with a given effect.

void

vibrate(long[] pattern, int repeat, AudioAttributes attributes)

This method was deprecated in API level 26. Use vibrate(android.os.VibrationEffect, android.os.VibrationAttributes) instead.


Inherited methods - From class java.lang.Object:

From class java.lang.Object

Description

Object

clone()

Creates and returns a copy of this object.

boolean

equals(Object obj)

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

void

finalize()

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

final Class<?>

getClass()

Returns the runtime class of this Object.

int

hashCode()

Returns a hash code value for the object.

final void

notify()

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

final void

notifyAll()

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

String

toString()

Returns a string representation of the object.

final void

wait(long timeout, int nanos)

Causes the current thread to wait until another thread invokes the notify() method or the notifyAll() method for this object, or some other thread interrupts the current thread, or a certain amount of real time has elapsed.

final void

wait(long timeout)

Causes the current thread to wait until either another thread invokes the notify() method or the notifyAll() method for this object, or a specified amount of time has elapsed.

final void

wait()

Causes the current thread to wait until another thread invokes the notify() method or the notifyAll() method for this object.


primitiveIds:

primitiveIds

Constant Value

primitiveIds

int: Which primitives to query for. This value cannot be null. Value is

 

VibrationEffect.Composition.PRIMITIVE_CLICK,

1 (0x00000001)

VibrationEffect.Composition.PRIMITIVE_THUD,

2 (0x00000002)

VibrationEffect.Composition.PRIMITIVE_SPIN,

3 (0x00000003)

VibrationEffect.Composition.PRIMITIVE_QUICK_RISE,

4 (0x00000004)

VibrationEffect.Composition.PRIMITIVE_SLOW_RISE,

5 (0x00000005)

VibrationEffect.Composition.PRIMITIVE_QUICK_FALL,

6 (0x00000006)

VibrationEffect.Composition.PRIMITIVE_LOW_TICK

8 (0x00000008)

VibrationEffect.Composition.PRIMITIVE_TICK

7 (0x00000007)


effectIds:

effectIds

Constant Value

effectIds

int: Which effects to query for. This value cannot be null. Value is

 

VibrationEffect.EFFECT_TICK, VibrationEffect

2 (0x00000002)

VibrationEffect.EFFECT_HEAVY_CLICK

5 (0x00000005)

EFFECT_CLICK

0 (0x00000000)

EFFECT_DOUBLE_CLICK

1 (0x00000001)

DEFAULT_AMPLITUDE

-1 (0xffffffff)


2022年 3月 31日(Thu)天氣報告
氣溫:41.0°F / 5.0°C @ 07:00
風速:每小時 6公里
降雨機會:5%
相對濕度:百分之 88%
天氣:多雲

沒有留言:

張貼留言