Android实现调用震动的方法

2019-12-10 19:54:32刘景俊

易采站长站为您分析Android实现调用震动的方法,实例分析了Android中Vibrator类的调用与使用技巧,具有一定参考借鉴价值,需要的朋友可以参考下

本文实例讲述了Android实现调用震动的方法。,具体如下:

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

 

 
  1. <?xml version="1.0" encoding="utf-8"?>  <manifest xmlns:android="http://www.easck.com/apk/res/android" 
  2. package="uni.vibrator"  android:versionCode="1" 
  3. android:versionName="1.0">  <uses-sdk android:minSdkVersion="8" /> 
  4. <application android:icon="@drawable/icon" android:label="@string/app_name">  <activity android:name=".VibratorDemoActivity" 
  5. android:label="@string/app_name">  <intent-filter> 
  6. <action android:name="android.intent.action.MAIN" />  <category android:name="android.intent.category.LAUNCHER" /> 
  7. </intent-filter>  </activity> 
  8. </application>  <uses-permission android:name="android.permission.VIBRATE" /> 
  9. </manifest> 

下面还是一起学习一下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)