Example usage for android.hardware SensorEvent toString

List of usage examples for android.hardware SensorEvent toString

Introduction

In this page you can find the example usage for android.hardware SensorEvent toString.

Prototype

public String toString() 

Source Link

Document

Returns a string representation of the object.

Usage

From source file:alaindc.crowdroid.SensorsIntentService.java

public final void onSensorChanged(SensorEvent event) {
    Log.d("SENSORS_INTENTSERVICE", event.toString());

    // Hack Reduce updates
    if (random.nextInt(10) < 9)
        return;//from w ww . ja v a2 s  .co m

    SharedPreferences sharedPref = getApplicationContext().getSharedPreferences(Constants.PREF_FILE,
            Context.MODE_PRIVATE);
    SharedPreferences.Editor editor = sharedPref.edit();
    editor.putString(Constants.PREF_SENSOR_ + event.sensor.getType(), Float.toString(event.values[0]));
    editor.commit();

    // Update view
    Intent senseintent = new Intent(Constants.INTENT_UPDATE_SENSORS);
    senseintent.putExtra(Constants.INTENT_RECEIVED_DATA_EXTRA_DATA, "Sensor "
            + Constants.getNameOfSensor(event.sensor.getType()) + " value: " + Float.toString(event.values[0]));
    LocalBroadcastManager.getInstance(this).sendBroadcast(senseintent);
}