【发布时间】:2013-07-21 22:42:26
【问题描述】:
我有以下代码给我一些传感器数据:
private void computeOrientation() {
if (SensorManager.getRotationMatrix(m_rotationMatrix, null, m_lastAccels, m_lastMagFields)) {
SensorManager.getOrientation(m_rotationMatrix, m_orientation);
/* 1 radian = 57.2957795 degrees */
/*
* [0] : yaw, rotation around z axis [1] : pitch, rotation around x
* axis [2] : roll, rotation around y axis
*/
float yaw = m_orientation[0] * 57.2957795f;
float pitch = m_orientation[1] * 57.2957795f;
float roll = m_orientation[2] * 57.2957795f;
/* append returns an average of the last 10 values */
m_lastYaw = m_filters[0].append(yaw);
m_lastPitch = m_filters[1].append(pitch);
m_lastRoll = m_filters[2].append(roll);
yawText.setText("azi z: " + m_lastYaw);
pitchText.setText("pitch x: " + m_lastPitch);
rollText.setText("roll y: " + m_lastRoll);
//Now I want to send those 3 values over the network
//whenever they're calculated
}
我估计每隔几毫秒就会调用一次这个函数,来自onSensorChanged(SensorEvent event)。
我想通过 Internet 网络不断地将这些数据发送/流式传输到远程设备,该设备将使用数据流实时计算事物。
我应该怎么做?通过插座?一个异步任务?非常感谢您的入门示例源代码 =)
【问题讨论】:
-
我也有同样的问题,我正在通过 WIFI 从 3 个传感器读取数据,但是数据流有时会停止几秒钟,而当我们运行良好(无任何延迟地获得连续数据流)时在 android 上启用 AIRPLANE 模式。如何解决?
标签: java android networking