android传感器总结
基于方向传感器的一个小应用——指北针(高手勿喷)
注释比较多
http://www.iteye.com/topic/737999
android 重力感应的使用
http://blog.csdn.net/pku_android/article/details/7438745
Android的传感器编程小结
http://www.cnblogs.com/nio-nio/archive/2009/10/23/1588610.html
Android方向传感器实践——自己动手做水平尺
http://blog.csdn.net/tinya0913/article/details/6095307
http://disanji.net/2011/08/30/android%E6%B8%B8%E6%88%8F%E5%BC%80%E5%8F%91%E4%B9%8B%E5%B0%8F%E7%90%83%E9%87%8D%E5%8A%9B%E6%84%9F%E5%BA%94%E5%AE%9E%E7%8E%B0/
http://hi.baidu.com/lieal/blog/item/f8ec3fed7aa8a4ccb21cb128.html
http://hi.baidu.com/huareal/blog/item/c5179bc6ac566021e5dd3bf1.html
Android设备信息获取
android.os.Build 包
Log.d(TAG, "device name : " +Build.MODEL);
HTC a510e 传感器支持情况:
04-22 23:54:43.003: D/debug(12091): BMA150 3-axis Accelerometer04-22 23:54:43.003: D/debug(12091): AK8973 3-axis Magnetic field sensor04-22 23:54:43.003: D/debug(12091): AK8973 Orientation sensor04-22 23:54:43.003: D/debug(12091): CM3602 Proximity sensor04-22 23:54:43.003: D/debug(12091): CM3602 Light sensor04-22 23:54:43.003: D/debug(12091): Gravity Sensor04-22 23:54:43.003: D/debug(12091): Linear Acceleration Sensor04-22 23:54:43.013: D/debug(12091): Rotation Vector Sensor
st18i 传感器支持情况:
04-23 00:18:25.314: D/debug(8972): BMA150 accelerometer04-23 00:18:25.314: D/debug(8972): AK8975 Compass04-23 00:18:25.314: D/debug(8972): AK8975 Compass Raw04-23 00:18:25.314: D/debug(8972): AK8975 Magnetic Field04-23 00:18:25.314: D/debug(8972): APDS9702 Proximity04-23 00:18:25.314: D/debug(8972): Gravity Sensor04-23 00:18:25.314: D/debug(8972): Linear Acceleration Sensor04-23 00:18:25.314: D/debug(8972): Rotation Vector Sensor
DrawGlobe extends GLBase{ private final float R = 0.5f; private final int N = 50; private final int T = 6; private final int M = 9; private final int NT = N * (T + M) - 1; private final float Start = (float)Math.PI / 2; private final float BASE = 2 * (float)Math.PI / N; private final float ADD_1 = (float)Math.PI / T; private final float ADD_2 = (float)Math.PI / (M - 1); private final int LEN = 3 * NT; private float an = 1; private float[] coords; FloatBuffer coordBuffer; private void setCoords() { coords = new float[LEN]; int i, j, k, p, pos; float angle = -ADD_1, rad, x1; for(k = 0, p = 0; k < T; k++) { angle += ADD_1; for (i = 0; i < N; i++, p++) { pos = p * 3; rad = i * BASE + Start; x1 = R * (float)Math.cos(rad); coords[pos] = x1 * (float)Math.cos(angle); coords[pos + 1] = R * (float)Math.sin(rad); coords[pos + 2] = x1 * (float)Math.sin(angle); } } float alpha = Start, beta = 0; float y, r; int ra = N /((M - 1) * 2); for(k = 1; k < M; k++) { beta += ADD_2; y = R * (float)Math.cos(beta); for(j = 0; j < ra; j++,p++) { pos = p * 3; rad = alpha - j * BASE; coords[pos] = R * (float)Math.cos(rad); coords[pos + 1] = R * (float)Math.sin(rad); coords[pos + 2] = 0; } alpha -= ADD_2; if(alpha == -Start) break; for(i = 0; i < N; i++, p++) { pos = p * 3; rad = i * BASE; r = R * (float)Math.sin(beta); coords[pos] = r * (float)Math.cos(rad); coords[pos + 1] = y; coords[pos + 2] = r * (float)Math.sin(rad); } } alpha = -Start; for(i = 0; i < N/2; i++,p++) { pos = p * 3; rad = i * BASE + alpha; coords[pos] = R * (float)Math.cos(rad); coords[pos + 1] = R * (float)Math.sin(rad); coords[pos + 2] = 0; } } public DrawGlobe(Context c) { super(c); setCoords(); coordBuffer = makeFloatBuffer(coords); } private void initial(GL10 gl) { an += 1.0; if(an == 360.0) an = 0; gl.glClear(GL10.GL_COLOR_BUFFER_BIT | GL10.GL_DEPTH_BUFFER_BIT); gl.glLoadIdentity(); gl.glEnableClientState(GL10.GL_VERTEX_ARRAY); } private void destroy(GL10 gl) { gl.glDisableClientState(GL10.GL_VERTEX_ARRAY); } @Override protected void drawFrame(GL10 gl) { initial(gl); draw(gl); destroy(gl); } private void draw(GL10 gl) { gl.glEnable(GL10.GL_DEPTH_TEST); gl.glColor4f(0.5f, 0, 1, 1); gl.glViewport(0, 0, 480, 480); gl.glRotatef(an, 0, 1f, 0); gl.glRotatef(an, 1f, 1f, 0); gl.glVertexPointer(3, GL10.GL_FLOAT, 0, coordBuffer); gl.glDrawArrays(GL10.GL_LINE_LOOP, 0, NT); } }这样就可以画出一个球了!
android 完整游戏源码(alignbody)
http://wanran.iteye.com/blog/1049401
package com.ray.test; import Android.app.Activity; import Android.os.Bundle; import Android.hardware.SensorManager; import Android.hardware.Sensor; import Android.hardware.SensorEventListener; import Android.hardware.SensorEvent; public class SensorTest extends Activity { private SensorManager sensorMgr; Sensor sensor = sensorMgr.getDefaultSensor(Sensor.TYPE_ACCELEROMETER); private float x, y, z; protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); sensorMgr = (SensorManager) getSystemService(SENSOR_SERVICE); SensorEventListener lsn = new SensorEventListener() { public void onSensorChanged(SensorEvent e) { x = e.values[SensorManager.DATA_X]; y = e.values[SensorManager.DATA_Y]; z = e.values[SensorManager.DATA_Z]; setTitle("x="+(int)x+","+"y="+(int)y+","+"z="+(int)z); } public void onAccuracyChanged(Sensor s, int accuracy) { } }; //注册listener,第三个参数是检测的精确度 sensorMgr.registerListener(lsn, sensor, SensorManager.SENSOR_DELAY_GAME); } }