当前位置:操作系统 > 安卓/Android >>

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 ,
CopyRight © 2022 站长资源库 编程知识问答 zzzyk.com All Rights Reserved
部分文章来自网络,