title: Getting values from two types of sensors in android
body: <p>Good day all, I'm trying to make an app with two types of sensors(ACCELEROMETER &amp; LIGHT) and I need their values to change profile or whatever I want. The problem is I can't figure it out how to get values from different sensors. Here are my codes,</p>
  
  <pre><code>@Override
  public void onSensorChanged(SensorEvent event) {
      Sensor mySensor = event.sensor;
      Sensor LightSense = event.sensor;
      if (mySensor.getType() == Sensor.TYPE_ACCELEROMETER &amp;&amp; LightSense.getType() == Sensor.TYPE_LIGHT) {
          float x = event.values[0];
          float y = event.values[1];
          float z = event.values[2];
          float light = event.values[0];
  
          long curTime = System.currentTimeMillis();
  
          if ((curTime - lastUpdate) &gt; 100) {
              lastUpdate = curTime;
  
              if (light&lt;=100) {
                  myAudManHolder.silent();
              }else if (x&lt;=0 &amp;&amp; y&lt;=0 &amp;&amp; z&lt;=+9){
                  myAudManHolder.ring();
              }else if (x&lt;=2 &amp;&amp; y&lt;=-7 &amp;&amp; z&lt;=-1){
                  myAudManHolder.vibrate();
              }
          }
      }   
  }
  </code></pre>
  
  <p>How can I get the values from ACCELEROMETER &amp; LIGHT sensors both? Your help would be really appreciable. Tnx.</p>