Пример #1
0
  @Override
  protected void onCreate(Bundle savedInstanceState) {

    super.onCreate(savedInstanceState);

    setContentView(R.layout.activity_wave);

    stopService(new Intent(this, WaveService.class));
    WaveService.getListener().stop();
    initView();

    mVibrator = (Vibrator) getApplication().getSystemService(VIBRATOR_SERVICE);

    // 检查设备是否有震动装置

    // mVibrator.hasVibrator();

    loadSound();

    mShakeListener = new ShakeListener(this);

    // 监听到手机摇动

    mShakeListener.setOnShakeListener(
        new OnShakeListener() {

          public void onShake() {

            startAnim();
          }
        });
    startAnim();
  }
Пример #2
0
  @Override
  protected void onDestroy() {

    // TODO Auto-generated method stub
    WaveService.getListener().start();
    super.onDestroy();

    if (mShakeListener != null) {

      mShakeListener.stop();
    }
  }