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


Java Sensor.TYPE_LIGHT屬性代碼示例

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


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

示例1: onSensorChanged

@Override
public void onSensorChanged(SensorEvent event) {
    if(event.sensor.getType() == Sensor.TYPE_LIGHT){
        mLightReading = event.values[0];
        if(mLightReading<20) {
            text_lightreading.setText("LIGHT: " + mLightReading + "; " + "Low light condition!");
        } else {
            text_lightreading.setText("LIGHT: " + mLightReading);
        }
    }
}
 
開發者ID:publiclab,項目名稱:SmART-Form,代碼行數:11,代碼來源:CameraActivity.java

示例2: onSensorChanged

@Override
public void onSensorChanged(SensorEvent sensorEvent) {
    if(sensorEvent.sensor.getType() == Sensor.TYPE_LIGHT) {
        synchronized (this.mutex) {
            this.lux = sensorEvent.values[0];
            logger.debug("Sensor light value : " + this.lux);
            System.out.println("Sensor light value : " + this.lux);
        }
    }
}
 
開發者ID:ros2java-alfred,項目名稱:ros2_android,代碼行數:10,代碼來源:LightSensorAdapter.java

示例3: onSensorChanged

@Override
public void onSensorChanged(SensorEvent event) {
    int type = event.sensor.getType();
    String luminosity_value;
    String magnetic_value;

    switch (type) {
        case Sensor.TYPE_MAGNETIC_FIELD:
            if ((System.currentTimeMillis() - lastUpdateSensorMagnetic) < Utils.SAMPLE_MILLIS) {
                break;
            }
            magnetic_value = Math.round(event.values[0]) + ", " + Math.round(event.values[1]) + ", " + Math.round(event.values[2]);
            real_magnetic_value = event.values[0] + ", " + event.values[1] + ", " + event.values[2];
            bt_magnetic_sample.setText(magnetic_value + " (uT)");
            bt_magnetic_sample.setEnabled(true);
            lastUpdateSensorMagnetic = System.currentTimeMillis();
            break;

        case Sensor.TYPE_LIGHT:
            if ((System.currentTimeMillis() - lastUpdateSensorLuminosity) < Utils.SAMPLE_MILLIS) {
                break;
            }
            luminosity_value = event.values[0] + "lx";
            bt_luminosity_sample.setText(luminosity_value);
            bt_luminosity_sample.setEnabled(true);
            lastUpdateSensorLuminosity = System.currentTimeMillis();
            break;
        default:
            break;
    }
}
 
開發者ID:feup-infolab,項目名稱:labtablet,代碼行數:31,代碼來源:FieldModeActivity.java

示例4: 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

示例5: LightUpdatesProvider

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

示例6: BrightnessMonitor

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

示例7: onSensorChanged

public void onSensorChanged(SensorEvent event) {
    long curTime = System.currentTimeMillis();
    // only allow one update every 100ms.
    if (event.sensor.getType() == Sensor.TYPE_LIGHT) {
        if ((curTime - lastUpdate) > CHECK_INTERVAL) {
            long diffTime = (curTime - lastUpdate);
            lastUpdate = curTime;

            current_values = event.values.clone();

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

            if (last_values != null) {

                boolean isChanged = false;

                float lightChangedValue = Math.abs(last_values[0]-current_values[0]);

                Log.d("LightSensor","Light changed: " + lightChangedValue);

                //see if light value changed more than 10 values
                isChanged = lightChangedValue >LIGHT_CHANGE_THRESHOLD;


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

                    alert = true;
                    remainingAlertPeriod = maxAlertPeriod;

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

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

示例8: PLightIntensity

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

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


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