當前位置: 首頁>>代碼示例>>Java>>正文


Java Sensor.TYPE_PRESSURE屬性代碼示例

本文整理匯總了Java中android.hardware.Sensor.TYPE_PRESSURE屬性的典型用法代碼示例。如果您正苦於以下問題:Java Sensor.TYPE_PRESSURE屬性的具體用法?Java Sensor.TYPE_PRESSURE怎麽用?Java Sensor.TYPE_PRESSURE使用的例子?那麽, 這裏精選的屬性代碼示例或許可以為您提供幫助。您也可以進一步了解該屬性所在android.hardware.Sensor的用法示例。


在下文中一共展示了Sensor.TYPE_PRESSURE屬性的12個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: onSensorChanged

@Override
public void onSensorChanged(SensorEvent event) {
    final float value = event.values[0];

    if (event.sensor.getType() == Sensor.TYPE_AMBIENT_TEMPERATURE) {
        updateTemperatureDisplay(value);
    } else if (event.sensor.getType() == Sensor.TYPE_PRESSURE) {
        updateBarometerDisplay(value);
    }
}
 
開發者ID:googlecodelabs,項目名稱:androidthings-weatherstation,代碼行數:10,代碼來源:WeatherStationActivity.java

示例2: onSensorChanged

@Override
public void onSensorChanged(SensorEvent sensorEvent) {
    switch (sensorEvent.sensor.getType()) {
        case Sensor.TYPE_AMBIENT_TEMPERATURE:
            mSensorData.temperature = sensorEvent.values[0];
            mSensorData.temperature_timestamp = sensorEvent.timestamp;
            break;
        case Sensor.TYPE_RELATIVE_HUMIDITY:
            mSensorData.humidity = sensorEvent.values[0];
            mSensorData.humidity_timestamp = sensorEvent.timestamp;
            break;
        case Sensor.TYPE_PRESSURE:
            mSensorData.pressure = sensorEvent.values[0];
            mSensorData.pressure_timestamp = sensorEvent.timestamp;
            break;
        case Sensor.TYPE_DEVICE_PRIVATE_BASE:
             if (HpmSensorDriver.SENSOR_STRING_TYPE.equals(sensorEvent.sensor.getStringType())) {
                mSensorData.pm25 = (int) sensorEvent.values[0];
                mSensorData.pm10 = (int) sensorEvent.values[1];
                mSensorData.particle_timestamp = sensorEvent.timestamp;
                break;
            }
        default:
            Log.w(TAG, "Unexpected sensor type: " + sensorEvent.sensor.getType());
    }
}
 
開發者ID:jpuderer,項目名稱:Taxi-Datalogger,代碼行數:26,代碼來源:DataLoggerActivity.java

示例3: onSensorChanged

@Override
public void onSensorChanged(SensorEvent event) {
    // when pressure value is changed, this method will be called.
    float pressure_value = 0.0f;

    // if you use this listener as listener of only one sensor (ex, Pressure), then you don't need to check sensor type.
    if( Sensor.TYPE_PRESSURE == event.sensor.getType() ) {
        pressure_value = event.values[0];
        //mAddressLabel = (TextView)findViewById(R.id.hostlobby_address);
        // mAddressLabel.setText(String.valueOf(pressure_value));

        mCurrentPressure = pressure_value;
    }
}
 
開發者ID:mattdelsordo,項目名稱:420Game,代碼行數:14,代碼來源:JoinLobbyActivity.java

示例4: onSensorChanged

@RequiresApi(api = Build.VERSION_CODES.CUPCAKE)
@Override
public void onSensorChanged(SensorEvent event) {
    // when pressure value is changed, this method will be called.
    float pressure_value = 0.0f;

    // if you use this listener as listener of only one sensor (ex, Pressure), then you don't need to check sensor type.
    if( Sensor.TYPE_PRESSURE == event.sensor.getType() ) {
        pressure_value = event.values[0];
        //mAddressLabel = (TextView)findViewById(R.id.hostlobby_address);
       // mAddressLabel.setText(String.valueOf(pressure_value));

        mCurrentPressure = pressure_value;
    }
}
 
開發者ID:mattdelsordo,項目名稱:420Game,代碼行數:15,代碼來源:HostLobbyActivity.java

示例5: onSensorChanged

@Override
public void onSensorChanged(SensorEvent event) {
    // when pressure value is changed, this method will be called.
    float pressure_value = 0.0f;

    // if you use this listener as listener of only one sensor (ex, Pressure), then you don't need to check sensor type.
    if (Sensor.TYPE_PRESSURE == event.sensor.getType()) {
        pressure_value = event.values[0];
        //mAddressLabel = (TextView)findViewById(R.id.hostlobby_address);
        // mAddressLabel.setText(String.valueOf(pressure_value));

        mCurrentPressure = pressure_value;
    }
}
 
開發者ID:mattdelsordo,項目名稱:420Game,代碼行數:14,代碼來源:GameActivity.java

示例6: onSensorChanged

@Override
public void onSensorChanged(SensorEvent sensorEvent) {
    if(sensorEvent.sensor.getType() == Sensor.TYPE_PRESSURE) {
        synchronized (this.mutex) {
            this.pressure = sensorEvent.values[0];

            logger.debug("Sensor Barometer value : " + this.pressure);
            System.out.println("Sensor Barometer value : " + this.pressure);
        }
    }
}
 
開發者ID:ros2java-alfred,項目名稱:ros2_android,代碼行數:11,代碼來源:BarometerSensorAdapter.java

示例7: isRestricted

@SuppressWarnings("deprecation")
private boolean isRestricted(XParam param, int type) throws Throwable {
	if (type == Sensor.TYPE_ALL)
		return false;
	else if (type == Sensor.TYPE_ACCELEROMETER || type == Sensor.TYPE_LINEAR_ACCELERATION) {
		if (isRestricted(param, "acceleration"))
			return true;
	} else if (type == Sensor.TYPE_GRAVITY) {
		if (isRestricted(param, "gravity"))
			return true;
	} else if (type == Sensor.TYPE_RELATIVE_HUMIDITY) {
		if (isRestricted(param, "humidity"))
			return true;
	} else if (type == Sensor.TYPE_LIGHT) {
		if (isRestricted(param, "light"))
			return true;
	} else if (type == Sensor.TYPE_MAGNETIC_FIELD || type == Sensor.TYPE_MAGNETIC_FIELD_UNCALIBRATED) {
		if (isRestricted(param, "magnetic"))
			return true;
	} else if (type == Sensor.TYPE_SIGNIFICANT_MOTION) {
		if (isRestricted(param, "motion"))
			return true;
	} else if (type == Sensor.TYPE_ORIENTATION || type == Sensor.TYPE_GYROSCOPE
			|| type == Sensor.TYPE_GYROSCOPE_UNCALIBRATED) {
		if (isRestricted(param, "orientation"))
			return true;
	} else if (type == Sensor.TYPE_PRESSURE) {
		if (isRestricted(param, "pressure"))
			return true;
	} else if (type == Sensor.TYPE_PROXIMITY) {
		if (isRestricted(param, "proximity"))
			return true;
	} else if (type == Sensor.TYPE_GAME_ROTATION_VECTOR || type == Sensor.TYPE_GEOMAGNETIC_ROTATION_VECTOR
			|| type == Sensor.TYPE_ROTATION_VECTOR) {
		if (isRestricted(param, "rotation"))
			return true;
	} else if (type == Sensor.TYPE_TEMPERATURE || type == Sensor.TYPE_AMBIENT_TEMPERATURE) {
		if (isRestricted(param, "temperature"))
			return true;
	} else if (type == Sensor.TYPE_STEP_COUNTER || type == Sensor.TYPE_STEP_DETECTOR) {
		if (isRestricted(param, "step"))
			return true;
	} else if (type == Sensor.TYPE_HEART_RATE) {
		if (isRestricted(param, "heartrate"))
			return true;
	} else if (type == 22) {
		// 22 = TYPE_TILT_DETECTOR
		// Do nothing
	} else if (type == 23 || type == 24 || type == 25) {
		// 23 = TYPE_WAKE_GESTURE
		// 24 = TYPE_GLANCE_GESTURE
		// 25 = TYPE_PICK_UP_GESTURE
		// 23/24 This sensor is expected to only be used by the system ui
		// 25 Expected to be used internally for always on display
	} else
		Util.log(this, Log.WARN, "Unknown sensor type=" + type);
	return false;
}
 
開發者ID:ukanth,項目名稱:XPrivacy,代碼行數:58,代碼來源:XSensorManager.java

示例8: AirPressureUpdatesProvider

AirPressureUpdatesProvider(int sensorDelay) {
    super(Sensor.TYPE_PRESSURE, sensorDelay);
}
 
開發者ID:PrivacyStreams,項目名稱:PrivacyStreams,代碼行數:3,代碼來源:AirPressureUpdatesProvider.java

示例9: PressureMonitor

public PressureMonitor(Context ctx, SensorManager sensorManager, ServerConnection serverConnection) throws SensorMissingException {
    super(ctx, sensorManager, serverConnection, "pressure", Sensor.TYPE_PRESSURE);
}
 
開發者ID:vbier,項目名稱:habpanelviewer,代碼行數:3,代碼來源:PressureMonitor.java

示例10: onSensorChanged

public void onSensorChanged(SensorEvent event) {
    long curTime = System.currentTimeMillis();

    // only allow one update every 100ms.
    if (event.sensor.getType() == Sensor.TYPE_PRESSURE) {

        if ((curTime - lastUpdate) > CHECK_INTERVAL) {
            long diffTime = (curTime - lastUpdate);
            lastUpdate = curTime;

            accel_values = event.values.clone();

            if (alert && remainingAlertPeriod > 0) {
                remainingAlertPeriod = remainingAlertPeriod - 1;
            } else {
                alert = false;
            }

            if (last_accel_values != null) {

                float diffValue = Math.abs(accel_values[0] - last_accel_values[0]);
                Log.d("Pressure","diff: " + diffValue);
                boolean logit = (diffValue > CHANGE_THRESHOLD);

                if (logit) {
		/*
		 * Send Alert
		 */

                    alert = true;
                    remainingAlertPeriod = maxAlertPeriod;

                    Message message = new Message();
                    message.what = EventTrigger.PRESSURE;
                    message.getData().putString("path",diffValue+"");

                    try {
                        if (serviceMessenger != null) {
                            serviceMessenger.send(message);
                        }
                    } catch (RemoteException e) {
                        // TODO Auto-generated catch block
                        e.printStackTrace();
                    }
                }
            }
            last_accel_values = accel_values.clone();
        }
    }
}
 
開發者ID:guardianproject,項目名稱:haven,代碼行數:50,代碼來源:BarometerMonitor.java

示例11: PPressure

public PPressure(AppRunner appRunner) {
    super(appRunner);

    type = Sensor.TYPE_PRESSURE;
}
 
開發者ID:victordiaz,項目名稱:phonk,代碼行數:5,代碼來源:PPressure.java

示例12: onSensorChanged

@Override
public void onSensorChanged(SensorEvent event) {
    switch (event.sensor.getType()) {
        case Sensor.TYPE_PRESSURE:
            if (groundCount > 3) {
                groundPressures.add(event.values[0]);
                if (groundPressures.size() > 4) {
                    publishAverageGroundPressure();
                }
                pressures.clear();
            } else {
                if (groundPressures.size() > 0) {
                    publishAverageGroundPressure();
                }
                pressures.offer(event.values[0]);
                if (pressures.size() > 4) {
                    pressures.poll();
                }
                publishAveragePressure();
            }
            break;
        case Sensor.TYPE_ACCELEROMETER:
            // keep running window of XYZ accelerations
            accelXWindow[windowIndex] = event.values[0];
            accelYWindow[windowIndex] = event.values[1];
            accelZWindow[windowIndex] = event.values[2];
            windowIndex = (windowIndex + 1) % 3;
            // find deviation on each axis
            float maxX = Math.max(accelXWindow[0], Math.max(accelXWindow[1], accelXWindow[2]));
            float minX = Math.min(accelXWindow[0], Math.min(accelXWindow[1], accelXWindow[2]));
            float maxY = Math.max(accelYWindow[0], Math.max(accelYWindow[1], accelYWindow[2]));
            float minY = Math.min(accelYWindow[0], Math.min(accelYWindow[1], accelYWindow[2]));
            float maxZ = Math.max(accelZWindow[0], Math.max(accelZWindow[1], accelZWindow[2]));
            float minZ = Math.min(accelZWindow[0], Math.min(accelZWindow[1], accelZWindow[2]));
            // use max deviation among the 3 axes
            float globalMax = Math.max(maxX - minX, Math.max(maxY - minY, maxZ - minZ));
            if (globalMax < GROUND_THRESHOLD) { // assume phone is on the ground
                groundCount++;
            } else { // assume phone is in user's hand
                groundCount = 0;
            }
            break;
    }
}
 
開發者ID:willowtreeapps,項目名稱:elevator-room,代碼行數:44,代碼來源:BarometerManager.java


注:本文中的android.hardware.Sensor.TYPE_PRESSURE屬性示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。