首页| JavaScript| HTML/CSS| Matlab| PHP| Python| Java| C/C++/VC++| C#| ASP| 其他|
购买积分 购买会员 激活码充值

您现在的位置是:虫虫源码 > Java > Android Sensor 各种传感器的使用例子

Android Sensor 各种传感器的使用例子

  • 资源大小:13.83 kB
  • 上传时间:2021-06-30
  • 下载次数:0次
  • 浏览次数:0次
  • 资源积分:1积分
  • 标      签: Android

资 源 简 介

本源码演示了Android Sensor 各种传感器的使用方法,比较基础的用法,例子中包括了方向传感器、磁场传感器、温度传感器、光传感器和压力传感器的各自调用用法等,相关代码如下:   public void onSensorChanged(SensorEvent event) {   float[] values = event.values;   StringBuffer sb = null;   int type = event.sensor.getType();   switch (type) {   case Sensor.TYPE_ORIENTATION:    sb = new StringBuffer();    sb.append("绕Z:" + values[0])    .append(" 绕X:" + values[1])    .append(" 绕X:" + values[2]);    ortationEdit.setText(sb.toString());    break;      case Sensor.TYPE_MAGNETIC_FIELD:    sb = new StringBuffer();    sb.append("X方向的角度:" + values[0])    .append(" Y方向的角度:" + values[1])    .append(" Z方向的角度:" + values[2]);    magneticEdit.setText(sb.toString());    break;   case Sensor.TYPE_TEMPERATURE:    sb = new StringBuffer();    sb.append("温度为:" + values[0]);    temeratureEdit.setText(sb.toString());    break;   case Sensor.TYPE_LIGHT:    sb = new StringBuffer();    sb.append("光强为:" + values[0]);    lightEdit.setText(sb.toString());    break;   case Sensor.TYPE_PRESSURE:    sb

文 件 列 表

srcfans.com
SensorSample
.project
SensorSample
SensorSample
.classpath
srcfans.com
VIP VIP
  • 睥睨 1天前 成为了本站会员

  • ? 1天前 成为了本站会员

  • IATWAY 2天前 成为了本站会员

  • 大智若愚 2天前 成为了本站会员

  • Mason 2天前 成为了本站会员

  • 2天前 成为了本站会员

  • Half_Punch 3天前 成为了本站会员

  • liqing71718 3天前 成为了本站会员

  • 伟国 3天前 成为了本站会员

  • songy 3天前 成为了本站会员

0.180673s