Struct droid_wrap::android::os::Vibrator
source · pub struct Vibrator { /* private fields */ }Expand description
- 操作设备上的振动器的类。如果您的进程退出,您启动的任何振动都将停止。
Implementations§
source§impl Vibrator
impl Vibrator
sourcepub const VIBRATION_INTENSITY_OFF: i32 = 0i32
pub const VIBRATION_INTENSITY_OFF: i32 = 0i32
振动强度:无振动。
sourcepub const VIBRATION_INTENSITY_LOW: i32 = 1i32
pub const VIBRATION_INTENSITY_LOW: i32 = 1i32
振动强度:低。
sourcepub const VIBRATION_INTENSITY_MEDIUM: i32 = 2i32
pub const VIBRATION_INTENSITY_MEDIUM: i32 = 2i32
振动强度:中。
sourcepub const VIBRATION_INTENSITY_HIGH: i32 = 3i32
pub const VIBRATION_INTENSITY_HIGH: i32 = 3i32
振动强度:高。
sourcepub const VIBRATION_EFFECT_SUPPORT_UNKNOWN: i32 = 0i32
pub const VIBRATION_EFFECT_SUPPORT_UNKNOWN: i32 = 0i32
振动效果支持:未知。 硬件未报告其支持的效果,因此我们无法确定是否支持该效果。
sourcepub const VIBRATION_EFFECT_SUPPORT_YES: i32 = 1i32
pub const VIBRATION_EFFECT_SUPPORT_YES: i32 = 1i32
振动效果支持:支持。 该效果由底层硬件支持。
sourcepub const VIBRATION_EFFECT_SUPPORT_NO: i32 = 2i32
pub const VIBRATION_EFFECT_SUPPORT_NO: i32 = 2i32
振动效果支持:不支持。 此效果并非底层硬件原生支持,但系统仍可播放后备振动。
sourcepub fn get_default_vibration_intensity(&self) -> i32
pub fn get_default_vibration_intensity(&self) -> i32
获取给定用途的默认振动强度。
sourcepub fn has_vibrator(&self) -> bool
pub fn has_vibrator(&self) -> bool
- 检查硬件是否有振动器。
- 返回:如果硬件有振动器则返回 True,否则返回 false。
sourcepub fn has_amplitude_control(&self) -> bool
pub fn has_amplitude_control(&self) -> bool
- 检查振动器是否具有振幅控制。
- 返回:如果硬件可以控制振动的振幅,则返回 True,否则返回 false。
sourcepub fn has_frequency_control(&self) -> bool
pub fn has_frequency_control(&self) -> bool
- 检查振动器是否具有独立的频率控制。
- 返回:如果硬件可以独立于振动幅度控制振动频率,则返回 True,否则返回 false。
sourcepub fn are_vibration_features_supported(&self, effect: &VibrationEffect) -> bool
pub fn are_vibration_features_supported(&self, effect: &VibrationEffect) -> bool
- 检查振动器是否支持给定 VibrationEffect 的所有组件(即振动器是否能按预期播放给定效果)。如果此方法返回 true,则 VibrationEffect 应按预期播放。 如果为 false,播放 VibrationEffect 仍可能产生振动,但振动效果可能与预期大不相同。此方法汇总功能检查方法的结果,例如 hasAmplitudeControl、areAllPrimitivesSupported(int…) 等,具体取决于 VibrationEffect 实际使用的功能。
- 返回:如果振动器可以按预期播放给定效果,则返回 true,否则返回 false。
effect要检查是否支持的 VibrationEffect
sourcepub fn has_external_control(&self) -> bool
pub fn has_external_control(&self) -> bool
- 使用 IExternalVibratorService 检查振动器是否可由外部服务控制。
- 返回:如果硬件可由外部服务控制,则返回 True,否则返回 false。
sourcepub fn get_resonant_frequency(&self) -> f32
pub fn get_resonant_frequency(&self) -> f32
- 获取振动器的共振频率(如果适用)。
- 返回:振动器的共振频率,如果未知、不适用或该振动器是具有不同频率的多个物理设备的组合,则返回 NaN。
sourcepub fn get_q_factor(&self) -> f32
pub fn get_q_factor(&self) -> f32
- 获取振动器的 Q 因子。
- 返回:振动器的 Q 因子,如果未知、不适用或该振动器是具有不同 Q 因子的多个物理设备的组合,则返回 NaN。
sourcepub fn get_haptic_channel_maximum_amplitude(&self) -> f32
pub fn get_haptic_channel_maximum_amplitude(&self) -> f32
- 返回振动器使用音频触觉通道可以播放的最大振幅。这是一个正值,如果未知则为 NaN。如果返回正值 maxAmplitude,则来自音轨触觉通道的信号应在 [-maxAmplitude, maxAmplitude] 范围内。
- 返回:一个正值,表示设备可以从音频触觉通道播放信号的最大绝对值,如果未知则为 NaN。
sourcepub fn vibrate(&self, milliseconds: i64)
👎Deprecated: 改用 vibrate(VibrationEffect)。
pub fn vibrate(&self, milliseconds: i64)
- 在指定的时间段内持续振动。应用应处于前台才能发生振动。
milliseconds振动的毫秒数。
sourcepub fn vibrate_effect(&self, vibe: &VibrationEffect)
pub fn vibrate_effect(&self, vibe: &VibrationEffect)
- 使用指定效果进行振动。应用程序应处于前台才能进行振动。
vibe描述要执行的振动的振动效果。
sourcepub fn cancel_usage_filter(&self, usage_filter: i32)
pub fn cancel_usage_filter(&self, usage_filter: i32)
- 取消特定类型的正在进行的振动。
usage_filter要取消的振动类型,表示为 VibrationAttributes 的按位组合。使用值。
sourcepub fn is_vibrating(&self) -> bool
pub fn is_vibrating(&self) -> bool
- 检查振动器是否正在振动。
- 返回:如果硬件正在振动,则返回 True,否则返回 false。
Methods from Deref<Target = GlobalRef>§
Methods from Deref<Target = JObject<'static>>§
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Vibrator
impl RefUnwindSafe for Vibrator
impl Send for Vibrator
impl Sync for Vibrator
impl Unpin for Vibrator
impl UnwindSafe for Vibrator
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more