Sensor(LIGHT)
package com.example.sensor01; import java.util.List; import android.hardware.Sensor;
import android.hardware.SensorEvent;
import android.hardware.SensorEventListener;
import android.hardware.SensorManager;
import android.os.Bundle;
import android.app.Activity;
import android.view.Menu;
import android.widget.TextView; public class MainActivity extends Activity implements SensorEventListener { private SensorManager mSensorManager;
private TextView textview; @Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main); textview = (TextView) findViewById(R.id.content); mSensorManager = (SensorManager) getSystemService(SENSOR_SERVICE); //光线感应传感器检测实时的光线强度,光强单位是lux,值越低,越暗
Sensor sensor = mSensorManager.getDefaultSensor(Sensor.TYPE_LIGHT); mSensorManager.registerListener(this, sensor,
SensorManager.SENSOR_DELAY_NORMAL); } @Override
public void onAccuracyChanged(Sensor arg0, int arg1) {
// TODO Auto-generated method stub
} @Override
public void onSensorChanged(SensorEvent event) { float light = 0; if (event.sensor.getType() == Sensor.TYPE_LIGHT) { light = event.values[0];
} textview.setText(String.valueOf(light)); }
}
Sensor(LIGHT)的更多相关文章
- 高通 8x26 andorid light sensor(TSL258x) 开发【转】
本文转载自:http://www.voidcn.com/blog/u012296694/article/p-1669831.html 前言 8926平台的sensor架构与之前的平台完全不同,实际上已 ...
- Sensor(PROXIMITY)
package com.example.sensor01; import android.hardware.Sensor; import android.hardware.SensorEvent; i ...
- Sensor(GYROSCOPE)
package com.example.sensor01; import java.util.List; import android.hardware.Sensor; import android. ...
- Sensor(ORIENTATION)
package com.example.sensor01; import java.util.List; import android.hardware.Sensor; import android. ...
- Sensor(ACCELEROMETER)
package com.example.sensor01; import java.util.List; import android.hardware.Sensor; import android. ...
- Android传感器编程带实例(转)
源:http://www.cnblogs.com/xiaochao1234/p/3894751.html 看了程序人生 网站的 编程高手的编程感悟 深有感触,好像也是一个android 程序员写的,推 ...
- UML类图(下):关联、聚合、组合、依赖
前言 上一篇文章UML类图(上):类.继承.实现,讲了UML类图中类.继承.实现三种关系及其在UML类图中的画法,本文将接着上文的内容,继续讲讲对象之间的其他几种关系,主要就是关联.聚合.组合.依赖, ...
- 王者荣耀是怎样炼成的(二)《王者荣耀》unity安装及使用的小白零基础入门
转载请注明出处:http://www.cnblogs.com/yuxiuyan/p/7535345.html 工欲善其事,必先利其器. 上回书说到,开发游戏用到unity和C#.本篇博客将从零开始做一 ...
- Unity-2017.2官方实例教程Roll-a-ball(二)
声明: 本文系转载,由于Unity版本不同,文中有一些小的改动,原文地址:http://www.jianshu.com/p/97b630a23234 上一节Unity-2017.2官方实例教程Roll ...
随机推荐
- 搭建调用 WebService 的 ASP.NET 网站 (VS2010, C#)
[系统环境]Windows 7 / 2008r2 [软件环境]Visual Studio 2010 [开发语言]C# [感谢]本文是在 <C#开发和调用Web Service> 一文的基础 ...
- cookie,session原理,以及如何使用chrome查看。
首先,先补充下chrome浏览器的使用. 1.1.php源码: <?php $cookieDomain = '.elf.com'; setcookie(, '/', $cookieDomain) ...
- Android studio下载依赖包很慢
build gradle文件 buildscript { repositories { //jcenter() maven { url 'http://maven.oschina.net/conten ...
- 123. Best Time to Buy and Sell Stock (三) leetcode解题笔记
123. Best Time to Buy and Sell Stock III Say you have an array for which the ith element is the pric ...
- arch linux 安装 之 ---GPT--引导篇
新入一二手X240 ,直接格式化,装archLinux. 一.引导程序安装--------------- 1.首先搞清楚什么是UEFI Under UEFI下的引导顺序 System switched ...
- cookie session URL重写 与考试
状态管理.Cookie.Session.URL重写 HTTP协议:无状态的连接(每次连接都是新的请求)1.隐藏字段 <input type="hidden" name=&qu ...
- interactivePopGestureRecognizer
苹果一直都在人机交互中尽力做到极致,在iOS7中,新增加了一个小小的功能,也就是这个api:self.navigationController.interactivePopGestureRecogni ...
- 'bool std::operator <(const std::_Tree<_Traits> &,const std::_Tree<_Traits> &)'
error C2784: 'bool std::operator <(const std::_Tree<_Traits> &,const std::_Tree<_Tra ...
- python 实现彻底删除文件夹和文件夹下的文件
python 中有很多内置库可以帮忙用来删除文件夹和文件,当面对要删除多个非空文件夹,并且目录层次大于3层以上时,仅使用一种内置方法是无法达到彻底删除文件夹和文件的效果的,比较low的方式是多次调用直 ...
- Win7 64位 VS2013环境编译Lua5.3.1
主要参考这篇文章,原文有几个错误顺便改正了. 在Windows下使用Visual Studio编译Lua5.3 写本文时Lua官方网站放出的新版本为5.3.1,然后我不知道为啥,神奇的国内不能访问Lu ...