- package com.ray.test;
-
- import android.app.Activity;
- import android.os.Bundle;
- import android.os.Vibrator;
- import android.view.MotionEvent;
-
- public class TestViberation extends Activity {
- Vibrator vibrator;
-
- @Override
- public void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- setContentView(R.layout.main);
- }
-
- @Override
- protected void onStop() {
- if(null!=vibrator){
- vibrator.cancel();
- }
- super.onStop();
- }
-
- @Override
- public boolean onTouchEvent(MotionEvent event) {
-
- if(event.getAction() == MotionEvent.ACTION_DOWN){
- vibrator = (Vibrator) getSystemService(VIBRATOR_SERVICE);
- long[] pattern = {800, 50, 400, 30};
- vibrator.vibrate(pattern, 2);
- }
- return super.onTouchEvent(event);
- }
-
-
- }
posted on
2011-11-17 15:26
情定诺坎普
阅读(
276)
评论()
编辑
收藏
举报