AndroidManifest.xml 获取系统权限

<uses-permission  android:name="android.permission.VIBRATE"/>

振动由Vibrator实现

Vibrator mVibrator = (Vibrator) mContext.getSystemService(Service.VIBRATOR_SERVICE);
//前一个参数为设置震动周期数组,第二个参数为震动次数(-1表示只震动一次,为0则震动会一直持续)
//或者直接设置振动时长 mVibrator.vibrate(5000);
long[] pattern = {150, 100};
mVibrator.vibrate(pattern, -1);
//取消震动
mVibrator.cancel();

让振动器振动起来——Vibrator的使用的更多相关文章

  1. Android加速度传感器实现“摇一摇”,带手机振动

    由于代码有点多,所以就分开写了,注释还算详细,方便学习 Activity package com.lmw.android.test;   import android.app.Activity; im ...

  2. Vibrator控制手机震动

    Vibrator控制手机震动 效果图 源码 下载地址(Android Studio工程):http://download.csdn.net/detail/q4878802/9049755 添加权限 & ...

  3. Andorid手机振动器(Vibrator)的使用

    标签: android vibrator 震动器 it 分类: Andorid 获取振动器Vibrator实例: Vibrator  mVibrator = (Vibrator) context.ge ...

  4. Android中振动器(Vibrator)的使用

    系统获取Vibrator也是调用Context的getSystemService方法,接下来就可以调用Vibrator的方法控制手机振动了.Vibrator只有三个方法控制手机振动: 1.vibrat ...

  5. Android_(服务)Vibrator振动器

    Vibrator振动器是Android给我们提供的用于机身震动的一个服务,例如当收到推送消息的时候我们可以设置震动提醒,也可以运用到游戏当中增强玩家互动性 运行截图: 程序结构 <?xml ve ...

  6. 使用Vibrator控制手机振动

    import android.os.Bundle;import android.os.Vibrator;import android.app.Activity;import android.app.S ...

  7. 振动器(Vibrator)

    package com.wwj.serviceandboardcast;   import android.app.Activity; import android.app.Service; impo ...

  8. Android 振动器

    今天介绍一下Android的振动器Vibrator,有三个方法来控制手机振动: 1.void vibrate(long milliseconds):控制手机振动milliseconds毫秒. 2.vo ...

  9. Android该系统提供的服务--Vibrator(振子)

    Android该系统提供的服务--Vibrator(振子) --转载请注明出处:coder-pig Vibrator简单介绍与相关方法: watermark/2/text/aHR0cDovL2Jsb2 ...

随机推荐

  1. Python入门--2--继续学习

    继续学习小甲鱼 一.python比较操作符 == :判断左边是否等于右边 != : 判断左边是否不能右边 二. if while判断语句 栗子: temp = input ("sha shu ...

  2. springmvc中ajax处理

    1.使用HttpServletResponse处理--不需要配置解析器 @Controller public class AjaxController { @RequestMapping(" ...

  3. grafana 安装 和 Nginx 、EL 联调

    https://blog.csdn.net/u010735147/article/details/80943593

  4. 创建ROS工作空间和包

    一.创建工作空间 mkdir -p ~/openni_ws/src cd ~/openni_ws catkin_make        //在catkin工作空间(openni_ws)下catkin_ ...

  5. 转:c++ 11 新特性

    声 明:本文源自 Danny Kalev 在 2011 年 6 月 21 日发表的<The Biggest Changes in C++11(and Why You Should Care)&g ...

  6. 【hibernate】报错:org.springframework.dao.DataIntegrityViolationException: could not execute statement; SQL [n/a]; nested exception is org.hibernate.exception.DataException: could not execute statement

    报错如下: org.springframework.dao.DataIntegrityViolationException: could not execute statement; SQL [n/a ...

  7. linux shell简单实现数据库自动备份

    以centos系统为例,实现数据库自动备份.1.写一个shell: 12 #! /bin/bashmysqldump -cp --user=root --password='123' dbName | ...

  8. 使用MVP模式重构代码

    之前写了两篇关于MVP模式的文章,主要讲得都是一些概念,这里谈谈自己在Android项目中使用MVP模式的真实感受,并以实例的形式一起尝试来使用MVP模式去重构我们现有的代码. 有兴趣的童鞋可以先去阅 ...

  9. 关于android分享(sharedsdk的简单使用)

    老早就使用了.可是如今才写,惰性太大,如今改 如今做产品的话相信大家基本都做分享吧.一个是项目的需求须要,另一个是能够非常好的宣传自己的产品.其它的优点依据情况而论 事实上每一个平台都有它自己的文档, ...

  10. Python基础语法05--函数模块

    Python 函数 函数是组织好的,可重复使用的,用来实现单一,或相关联功能的代码段. 函数能提高应用的模块性,和代码的重复利用率.你已经知道Python提供了许多内建函数,比如print().但你也 ...