title: Is it possible to send a notification to a user when the barometric pressure gets low?
body: <p>In my app, I want to send a notification to the user when the barometric pressure gets below a certain number.  </p>
  
  <p>I know I have to use an <code>if</code> statement, so I have been trying it for a few days now. I tried using the  <code>if</code> statement with a <code>TextView</code>, which gets the barometric pressure, but this hasn't worked......</p>
  
  <pre><code>public class MainActivity extends AppCompatActivity {
  
  
      private TextView txt;
      private SensorManager sensorManager;
      private Sensor pressureSensor;
      private SensorEventListener sensorEventListener = new SensorEventListener() {
  
          @Override
          public void onSensorChanged(SensorEvent sensorEvent) {
              float[] values = sensorEvent.values;
              txt.setText(String.format("%.3f mbar", values[0]));
          }
  
          @Override
          public void onAccuracyChanged(Sensor sensor, int i) {
          }
      };
  
      @Override
      protected void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          setContentView(R.layout.activity_main);
          txt = findViewById(R.id.barometric);
  
          //Here is the code I tried... But it is already underlined in red...
          if(barometric &lt; 90.5){
  
          }
  
          sensorManager = (SensorManager) getSystemService(SENSOR_SERVICE);
          pressureSensor = sensorManager.getDefaultSensor(Sensor.TYPE_PRESSURE);
  
          FloatingActionButton fab = (FloatingActionButton) findViewById(R.id.settings);
          fab.setOnClickListener(new View.OnClickListener() {
              @Override
              public void onClick(View view) {
                  startActivity(new Intent(MainActivity.this, Main2Activity.class));
              }
          });
      }
  
      @Override
      protected void onResume() {
          super.onResume();
          sensorManager.registerListener(sensorEventListener, pressureSensor, SensorManager.SENSOR_DELAY_UI);
      }
  
      @Override
      protected void onPause() {
          super.onPause();
          sensorManager.unregisterListener(sensorEventListener);
      }
  }
  </code></pre>