资源简介
跌倒检测器源码,利用加速度传感器,陀螺仪和地磁传感器实现跌倒检测
代码片段和文件信息
/*
*
* IBMEyes.java
* sample code for IBM Developerworks Article
* Author: W. Frank Ableson
* fableson@msiservices.com
*
*/
package com.msi.ibm.eyes;
import android.app.Activity;
import android.os.Bundle;
import android.util.Log;
import android.widget.TextView;
import android.hardware.SensorManager;
import android.hardware.SensorListener;
public class IBMEyes extends Activity implements SensorListener {
final String tag = “IBMEyes“;
SensorManager sm = null;
TextView xViewA = null;
TextView yViewA = null;
TextView zViewA = null;
TextView xViewO = null;
TextView yViewO = null;
TextView zViewO = null;
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
sm = (SensorManager) getSystemService(SENSOR_SERVICE);
setContentView(R.layout.main);
xViewA = (TextView) findViewById(R.id.xbox);
yViewA = (TextView) findViewById(R.id.ybox);
zViewA = (TextView) findViewById(R.id.zbox);
xViewO = (TextView) findViewById(R.id.xboxo);
yViewO = (TextView) findViewById(R.id.yboxo);
zViewO = (TextView) findViewById(R.id.zboxo);
}
public void onSensorChanged(int sensor float[] values) {
synchronized (this) {
Log.d(tag “onSensorChanged: “ + sensor + “ x: “ + values[0] + “ y: “ + values[1] + “ z: “ + values[2]);
if (sensor == SensorManager.SENSOR_ORIENTATION) {
xViewO.setText(“Orientation X: “ + values[0]);
yViewO.setText(“Orientation Y: “ + values[1]);
zViewO.setText(“Orientation Z: “ + values[2]);
}
if (sensor == SensorManager.SENSOR_ACCELEROMETER) {
xViewA.setText(“Accel X: “ + values[0]);
yViewA.setText(“Accel Y: “ + values[1]);
zViewA.setText(“Accel Z: “ + values[2]);
}
}
}
public void onAccuracyChanged(int sensor int accuracy) {
Log.d(tag“onAccuracyChanged: “ + sensor + “ accuracy: “ + accuracy);
}
@Override
protected void onResume() {
super.onResume();
sm.registerListener(this
SensorManager.SENSOR_ORIENTATION |
SensorManager.SENSOR_ACCELEROMETER
SensorManager.SENSOR_DELAY_NORMAL);
}
@Override
protected void onstop() {
sm.unregisterListener(this);
super.onstop();
}
}
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
文件 238 2009-04-16 17:30 Eyes\.classpath
文件 840 2009-04-16 17:30 Eyes\.project
文件 635 2009-04-16 17:30 Eyes\AndroidManifest.xm
目录 0 2009-04-16 17:30 Eyes\assets\
目录 0 2009-04-19 21:49 Eyes\bin\
文件 4460 2009-04-19 21:49 Eyes\bin\classes.dex
目录 0 2009-04-16 17:30 Eyes\bin\com\
目录 0 2009-04-16 17:30 Eyes\bin\com\msi\
目录 0 2009-04-16 17:30 Eyes\bin\com\msi\ibm\
目录 0 2009-04-16 23:30 Eyes\bin\com\msi\ibm\eyes\
文件 2855 2009-04-19 21:49 Eyes\bin\com\msi\ibm\eyes\IBMEyes.class
文件 334 2009-04-18 23:22 Eyes\bin\com\msi\ibm\eyes\R$attr.class
文件 394 2009-04-18 23:22 Eyes\bin\com\msi\ibm\eyes\R$drawable.class
文件 519 2009-04-18 23:22 Eyes\bin\com\msi\ibm\eyes\R$id.class
文件 388 2009-04-18 23:22 Eyes\bin\com\msi\ibm\eyes\R$layout.class
文件 421 2009-04-18 23:22 Eyes\bin\com\msi\ibm\eyes\R$string.class
文件 517 2009-04-18 23:22 Eyes\bin\com\msi\ibm\eyes\R.class
文件 9911 2009-04-19 21:49 Eyes\bin\Eyes.apk
文件 6106 2009-04-18 23:22 Eyes\bin\resources.ap_
目录 0 2009-04-16 17:30 Eyes\res\
目录 0 2009-04-16 17:30 Eyes\res\drawable\
文件 3180 2009-04-16 17:30 Eyes\res\drawable\icon.png
目录 0 2009-04-16 17:30 Eyes\res\layout\
文件 1641 2009-04-18 23:16 Eyes\res\layout\main.xm
目录 0 2009-04-16 17:30 Eyes\res\values\
文件 152 2009-04-18 23:22 Eyes\res\values\strings.xm
目录 0 2009-04-16 17:30 Eyes\src\
目录 0 2009-04-16 17:30 Eyes\src\com\
目录 0 2009-04-16 17:30 Eyes\src\com\msi\
目录 0 2009-04-16 17:30 Eyes\src\com\msi\ibm\
目录 0 2009-04-16 17:30 Eyes\src\com\msi\ibm\eyes\
............此处省略2个文件信息
评论
共有 条评论