title: Proximity Sensor to change button Color
body: <p>I'm trying to make an app that the color of the buttons change with the proximity sensor.</p>
  
  <p>I don't know quite how to change it on the <code>onSensorChanged</code> part. Must I have to import Color and implement different color states? I'm a bit confused.</p>
  
  <p>Here's my code:</p>
  
  <pre><code>public class MainProxmityActivity extends Activity implements SensorEventListener {
  
  Button proximidade;
  SensorManager Sm;
  Sensor ProxSensor;
  
  @Override
  protected void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.activity_main_proxmity);
  
      Sm = (SensorManager) getSystemService (SENSOR_SERVICE);
      ProxSensor = Sm.getDefaultSensor(Sensor.TYPE_PROXIMITY);
      proximidade = (Button) findViewById(R.id.btn_proximidade);
  
      Sm.registerListener(this, ProxSensor, SensorManager.SENSOR_DELAY_NORMAL);
  
  }
  
  @Override
  public boolean onCreateOptionsMenu(Menu menu) {
      // Inflate the menu; this adds items to the action bar if it is present.
      getMenuInflater().inflate(R.menu.main_proxmity, menu);
      return true;
  }
  
  @Override
  public void onAccuracyChanged(Sensor sensor, int accuracy) {
      // TODO Auto-generated method stub
  
  }
  
  @Override
  public void onSensorChanged(SensorEvent event) {
      // TODO Auto-generated method stub
      proximidade.setBackgroundColor(getTitleColor("bd4c31"));
  }
  
  }
  </code></pre>
  
  <p>Hope the question is clear.</p>