android 怎么调用震动,Android实现调用震动的方法

本文详细介绍了如何在Android中使用Vibrator类进行设备震动。通过设置long数组pattern来控制震动的开和关时间,并通过vibrate方法启动震动。此外,还展示了如何通过repeat参数实现震动模式的重复,以及使用cancel方法停止震动。提供的示例代码演示了如何在Activity中创建并使用Vibrator。
摘要由CSDN通过智能技术生成

本文实例讲述了Android实现调用震动的方法。分享给大家供大家参考,具体如下:

调用Android系统的震动,只需要一个类 那就是Vibrator ,这个类在hard包中,一看系统级的服务,又要通过manifest.xml文件设置权限了

package="uni.vibrator"

android:versionCode="1"

android:versionName="1.0">

android:label="@string/app_name">

下面还是一起学习一下SDK吧

Class that operates the vibrator on the device.

If your process exits, any vibration you started with will stop.

//Vibrator类用来操作设备上的震动,如果你的线程退出了,那么启动的震动也会停止

public void vibrate (long[] pattern, int repeat)

Since: API Level 1

Vibrate with a given pattern.  //根据给定的节奏震动

Pass in an array of ints that are the durations for which to turn on or off the vibrator in milliseconds. The first value indicates the number of milliseconds to wait before turning the vibrator on. The next va

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值