Search in sources :

Example 6 with Sensor

use of android.hardware.Sensor in project AndEngine by nicolasgramlich.

the class Engine method unregisterSelfAsSensorListener.

private void unregisterSelfAsSensorListener(final SensorManager pSensorManager, final int pType) {
    final Sensor sensor = pSensorManager.getSensorList(pType).get(0);
    pSensorManager.unregisterListener(this, sensor);
}
Also used : Sensor(android.hardware.Sensor)

Example 7 with Sensor

use of android.hardware.Sensor in project sensey by nisrulz.

the class SensorUtils method testSensor.

private static Sensor testSensor(int type) {
    Sensor sensor = mock(Sensor.class);
    when(sensor.getType()).thenReturn(type);
    return sensor;
}
Also used : Sensor(android.hardware.Sensor)

Example 8 with Sensor

use of android.hardware.Sensor in project robolectric by robolectric.

the class ShadowSensorManagerTest method registerListener.

private SensorEventListener registerListener() {
    SensorEventListener listener = new TestSensorEventListener();
    Sensor sensor = sensorManager.getDefaultSensor(SensorManager.SENSOR_ACCELEROMETER);
    sensorManager.registerListener(listener, sensor, SensorManager.SENSOR_DELAY_NORMAL);
    return listener;
}
Also used : SensorEventListener(android.hardware.SensorEventListener) Sensor(android.hardware.Sensor)

Example 9 with Sensor

use of android.hardware.Sensor in project platform_frameworks_base by android.

the class SensorPowerCalculator method calculateApp.

@Override
public void calculateApp(BatterySipper app, BatteryStats.Uid u, long rawRealtimeUs, long rawUptimeUs, int statsType) {
    // Process Sensor usage
    final SparseArray<? extends BatteryStats.Uid.Sensor> sensorStats = u.getSensorStats();
    final int NSE = sensorStats.size();
    for (int ise = 0; ise < NSE; ise++) {
        final BatteryStats.Uid.Sensor sensor = sensorStats.valueAt(ise);
        final int sensorHandle = sensorStats.keyAt(ise);
        final BatteryStats.Timer timer = sensor.getSensorTime();
        final long sensorTime = timer.getTotalTimeLocked(rawRealtimeUs, statsType) / 1000;
        switch(sensorHandle) {
            case BatteryStats.Uid.Sensor.GPS:
                app.gpsTimeMs = sensorTime;
                app.gpsPowerMah = (app.gpsTimeMs * mGpsPowerOn) / (1000 * 60 * 60);
                break;
            default:
                final int sensorsCount = mSensors.size();
                for (int i = 0; i < sensorsCount; i++) {
                    final Sensor s = mSensors.get(i);
                    if (s.getHandle() == sensorHandle) {
                        app.sensorPowerMah += (sensorTime * s.getPower()) / (1000 * 60 * 60);
                        break;
                    }
                }
                break;
        }
    }
}
Also used : BatteryStats(android.os.BatteryStats) Sensor(android.hardware.Sensor)

Example 10 with Sensor

use of android.hardware.Sensor in project JieCaoVideoPlayer by lipangit.

the class ApiActivity method onResume.

@Override
protected void onResume() {
    super.onResume();
    Sensor accelerometerSensor = mSensorManager.getDefaultSensor(Sensor.TYPE_ACCELEROMETER);
    mSensorManager.registerListener(mSensorEventListener, accelerometerSensor, SensorManager.SENSOR_DELAY_NORMAL);
}
Also used : Sensor(android.hardware.Sensor)

Aggregations

Sensor (android.hardware.Sensor)34 SensorEventListener (android.hardware.SensorEventListener)5 SensorManager (android.hardware.SensorManager)5 BatteryStats (android.os.BatteryStats)5 SensorEvent (android.hardware.SensorEvent)4 Handler (android.os.Handler)2 Intent (android.content.Intent)1 SharedPreferences (android.content.SharedPreferences)1 Resources (android.content.res.Resources)1 ViewPager (android.support.v4.view.ViewPager)1 View (android.view.View)1 ViewTreeObserver (android.view.ViewTreeObserver)1 Window (android.view.Window)1 AdapterView (android.widget.AdapterView)1 TextView (android.widget.TextView)1 InjectView (butterknife.InjectView)1 BmobUser (cn.bmob.v3.BmobUser)1 MaterialDialog (com.afollestad.materialdialogs.MaterialDialog)1 MaterialMenuView (com.balysv.materialmenu.MaterialMenuView)1 SuperActivityToast (com.github.johnpersano.supertoasts.SuperActivityToast)1