コード例 #1
0
 @Override
 protected void onCreate(Bundle savedInstanceState) {
   super.onCreate(savedInstanceState);
   Preferences.setScreenOn(this);
   mAudioManager = Global.getAudioManager(this);
   mSpeechRecognition = SpeechRecognition.getInstance(this);
 }
 public void setSensor(int sensorType) {
   mSensors = mSensorManager.getDefaultSensor(sensorType);
   Global.SensorsDebug(
       "MainSensorManager.setSensor(): Sensor name: "
           + mSensors.getName()
           + " Maximum sensor value: "
           + mSensors.getMaximumRange());
 }
 @Override
 public void onSensorChanged(SensorEvent event) {
   sensorSampleCounter++;
   sensorSampleCounter %= samplesFrequency;
   if (sensorSampleCounter == 0) {
     Global.SensorsDebug(
         "MainSensorManager.onSensorChanged(): values " + Arrays.toString(event.values));
     float[] newValues = Utils.lowPass(previousValues, event.values);
     previousValues = event.values;
     mCallback.onSensorValueChanged(newValues);
   }
 }
 @Override
 public void onAccuracyChanged(Sensor sensor, int accuracy) {
   Global.SensorsDebug("MainSensorManager.onAccuracyChanged(): accuracy: " + accuracy);
 }