【问题标题】:How to check for duration on shake in android?如何在android中检查抖动的持续时间?
【发布时间】:2015-12-04 03:14:41
【问题描述】:

我已经尝试过这段代码,但它似乎不能有效地检查抖动持续时间。长时间摇晃我想得到更远的经纬度。

@Override public void onSensorChanged(SensorEvent event){
        ImageView colorBox = (ImageView)findViewById(R.id.colorBox);
        TextView latText = (TextView)findViewById(R.id.latText);
        TextView lngText = (TextView)findViewById(R.id.longText);

        if(event.sensor.getType() == Sensor.TYPE_ACCELEROMETER){
            float[] values = event.values;
            float x = values[0];
            float y = values[1];
            float z = values[2];

            float acclt = (x*x+ y*y+ z*z)/(SensorManager.GRAVITY_EARTH*SensorManager.GRAVITY_EARTH);
            long actualTime = System.currentTimeMillis();
            if(acclt >2) {

            }
        }
    }

【问题讨论】:

    标签: android shake


    【解决方案1】:

    试试 Seismic 库: https://github.com/square/seismic

    演示应用展示了如何使用它。

    【讨论】:

      猜你喜欢
      • 2011-09-19
      • 1970-01-01
      • 1970-01-01
      • 2013-03-08
      • 2012-12-12
      • 2010-09-27
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多