本文整理匯總了Java中android.hardware.Sensor.TYPE_PROXIMITY屬性的典型用法代碼示例。如果您正苦於以下問題:Java Sensor.TYPE_PROXIMITY屬性的具體用法?Java Sensor.TYPE_PROXIMITY怎麽用?Java Sensor.TYPE_PROXIMITY使用的例子?那麽, 這裏精選的屬性代碼示例或許可以為您提供幫助。您也可以進一步了解該屬性所在類android.hardware.Sensor
的用法示例。
在下文中一共展示了Sensor.TYPE_PROXIMITY屬性的8個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: onSensorChanged
@Override
public void onSensorChanged(SensorEvent sensorEvent) {
float[] its = sensorEvent.values;
Log.d(TAG, String.format("its %f %f %f len:,%d", its[0], its[1], its[2], its.length));
if (sensorEvent.sensor.getType() == Sensor.TYPE_PROXIMITY) {
if (FuncUnit.isForeground(ClockApplication.getContext(), MainActivity.class.getName())) {
if (its[0] == 0.0) {
System.out.println("Hand stay");
if (ScreenManager.isScreenOn()) {
ScreenManager.systemLock(ClockApplication.getInstance().getMainActivity());
} else {
ScreenManager.systemUnLock();
}
} else {
System.out.println("Hand leave...");
}
}
}
}
示例2: onSensorChanged
@Override
public void onSensorChanged(SensorEvent sensorEvent) {
if(sensorEvent.sensor.getType()==Sensor.TYPE_PROXIMITY) {
if (sensorEvent.values.length > 0) {
String text = "Proximity: " + Math.round(sensorEvent.values[0]) + " cm";
Log.i(TAG, text);
if(distanceView!=null){
distanceView.setText(text);
}
}
}
}
示例3: onSensorChanged
@Override
public void onSensorChanged(SensorEvent event) {
if (event.sensor.getType() == Sensor.TYPE_PROXIMITY){
float currDistance = event.values[0];
L.i("currDistance:" + currDistance);
L.i("maximumRange:" + event.sensor.getMaximumRange());
if (currDistance >= event.sensor.getMaximumRange()){
request(AntiTheftService.REQUEST_START_ALARM, null);
}
}
}
示例4: onSensorChanged
@Override
public void onSensorChanged(SensorEvent sensorEvent) {
if(sensorEvent.sensor.getType() == Sensor.TYPE_PROXIMITY) {
synchronized (this.mutex) {
this.proximity = sensorEvent.values[0];
logger.debug("Sensor proximity value : " + this.proximity);
System.out.println("Sensor proximity value : " + this.proximity);
}
}
}
示例5: onSensorChanged
@Override
public void onSensorChanged(SensorEvent event) {
if (event.sensor.getType() != Sensor.TYPE_PROXIMITY) return;
if (mediaPlayer == null || !mediaPlayer.isPlaying()) return;
int streamType;
if (event.values[0] < 5f && event.values[0] != proximitySensor.getMaximumRange()) {
streamType = AudioManager.STREAM_VOICE_CALL;
} else {
streamType = AudioManager.STREAM_MUSIC;
}
if (streamType == AudioManager.STREAM_VOICE_CALL &&
mediaPlayer.getAudioStreamType() != streamType &&
!audioManager.isWiredHeadsetOn())
{
double position = mediaPlayer.getCurrentPosition();
double duration = mediaPlayer.getDuration();
double progress = position / duration;
if (wakeLock != null) wakeLock.acquire();
stop();
try {
play(progress, true);
} catch (IOException e) {
Log.w(TAG, e);
}
} else if (streamType == AudioManager.STREAM_MUSIC &&
mediaPlayer.getAudioStreamType() != streamType &&
System.currentTimeMillis() - startTime > 500)
{
if (wakeLock != null) wakeLock.release();
stop();
notifyOnStop();
}
}
示例6: 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;
}
示例7: ProximityMonitor
public ProximityMonitor(Context ctx, SensorManager sensorManager, ServerConnection serverConnection) throws SensorMissingException {
super(ctx, sensorManager, serverConnection, "proximity", Sensor.TYPE_PROXIMITY);
}
示例8: PProximity
public PProximity(AppRunner appRunner) {
super(appRunner);
type = Sensor.TYPE_PROXIMITY;
}