Android重力感应选号码
sensorMgr = (SensorManager) getSystemService(SENSOR_SERVICE);
SensorEventListener lsn = new SensorEventListener() {
@Override
public void onSensorChanged(SensorEvent e) {
// TODO Auto-generated method stub
x = (int) e.values[SensorManager.DATA_X];
y = (int) e.values[SensorManager.DATA_Y];
z = (int) e.values[SensorManager.DATA_Z];
if (x > 7 && y > 6 && z < 8) {
loveyou();
Toast.makeText(RandomActivity.this,
" 选号成功!!!\n\n祝君中500万大奖!\n", 2000).show();
}
}
@Override
public void onAccuracyChanged(Sensor sensor, int accuracy) {
// TODO Auto-generated method stub
}
};
Sensor sensor = sensorMgr.getDefaultSensor(Sensor.TYPE_ACCELEROMETER);// .SENSOR_ACCELEROMETER);
sensorMgr
.registerListener(lsn, sensor, SensorManager.SENSOR_DELAY_GAME /* SENSOR_DELAY_GAME */);
摘自 gongzibai的专栏
补充:移动开发 , Android ,