本文整理了Java中android.hardware.SensorManager.getSensorList()
方法的一些代码示例,展示了SensorManager.getSensorList()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。SensorManager.getSensorList()
方法的具体详情如下:
包路径:android.hardware.SensorManager
类名称:SensorManager
方法名:getSensorList
暂无
代码示例来源:origin: novoda/android-demos
private void registerMagSensor() {
if (sensorManager.getSensorList(Sensor.TYPE_MAGNETIC_FIELD).size() > 0) {
magFieldSensor = sensorManager.getSensorList(Sensor.TYPE_MAGNETIC_FIELD).get(FIRST_SENSOR_ITEM);
sensorManager.registerListener(this, magFieldSensor, SensorManager.SENSOR_DELAY_NORMAL);
}
};
代码示例来源:origin: novoda/android-demos
private void registerAcclSensor() {
if (sensorManager.getSensorList(Sensor.TYPE_ACCELEROMETER).size() > 0) {
acclSensor = sensorManager.getSensorList(Sensor.TYPE_ACCELEROMETER).get(FIRST_SENSOR_ITEM);
sensorManager.registerListener(this, acclSensor, SensorManager.SENSOR_DELAY_NORMAL);
}
};
代码示例来源:origin: commonsguy/cw-omnibus
@Override
public List<Sensor> getSensorList() {
List<Sensor> unfiltered=
new ArrayList<>(mgr.getSensorList(Sensor.TYPE_ALL));
List<Sensor> result=new ArrayList<>();
for (Sensor s : unfiltered) {
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.KITKAT
|| !isTriggerSensor(s)) {
result.add(s);
}
}
Collections.sort(result, new Comparator<Sensor>() {
@Override
public int compare(final Sensor a, final Sensor b) {
return(a.toString().compareTo(b.toString()));
}
});
return(result);
}
代码示例来源:origin: libgdx/libgdx
void registerSensorListeners () {
if (config.useAccelerometer) {
manager = (SensorManager)context.getSystemService(Context.SENSOR_SERVICE);
if (manager.getSensorList(Sensor.TYPE_ACCELEROMETER).isEmpty()) {
accelerometerAvailable = false;
} else {
Sensor accelerometer = manager.getSensorList(Sensor.TYPE_ACCELEROMETER).get(0);
accelerometerListener = new SensorListener();
accelerometerAvailable = manager.registerListener(accelerometerListener, accelerometer,
if (manager.getSensorList(Sensor.TYPE_GYROSCOPE).isEmpty()) {
gyroscopeAvailable = false;
} else {
Sensor gyroscope = manager.getSensorList(Sensor.TYPE_GYROSCOPE).get(0);
gyroscopeListener = new SensorListener();
gyroscopeAvailable = manager.registerListener(gyroscopeListener, gyroscope,
if (config.useRotationVectorSensor){
if (manager == null) manager = (SensorManager)context.getSystemService(Context.SENSOR_SERVICE);
List<Sensor> rotationVectorSensors = manager.getSensorList(Sensor.TYPE_ROTATION_VECTOR);
if (!rotationVectorSensors.isEmpty()){
rotationVectorListener = new SensorListener();
代码示例来源:origin: libgdx/libgdx
void registerSensorListeners () {
if (config.useAccelerometer) {
manager = (SensorManager)context.getSystemService(Context.SENSOR_SERVICE);
if (manager.getSensorList(Sensor.TYPE_ACCELEROMETER).isEmpty()) {
accelerometerAvailable = false;
} else {
Sensor accelerometer = manager.getSensorList(Sensor.TYPE_ACCELEROMETER).get(0);
accelerometerListener = new SensorListener();
accelerometerAvailable = manager.registerListener(accelerometerListener, accelerometer,
if (manager.getSensorList(Sensor.TYPE_GYROSCOPE).isEmpty()) {
gyroscopeAvailable = false;
} else {
Sensor gyroscope = manager.getSensorList(Sensor.TYPE_GYROSCOPE).get(0);
gyroscopeListener = new SensorListener();
gyroscopeAvailable = manager.registerListener(gyroscopeListener, gyroscope,
if (config.useRotationVectorSensor){
if (manager == null) manager = (SensorManager)context.getSystemService(Context.SENSOR_SERVICE);
List<Sensor> rotationVectorSensors = manager.getSensorList(Sensor.TYPE_ROTATION_VECTOR);
if (!rotationVectorSensors.isEmpty()){
rotationVectorListener = new SensorListener();
代码示例来源:origin: stackoverflow.com
Sensor accelerometer = manager.getSensorList(Sensor.TYPE_ACCELEROMETER).get(0);
manager.registerListener(this, accelerometer, SensorManager.SENSOR_DELAY_GAME);
代码示例来源:origin: robolectric/robolectric
@Test
public void shouldReturnASensorList() throws Exception {
assertThat(sensorManager.getSensorList(0)).isNotNull();
}
代码示例来源:origin: jMonkeyEngine/jmonkeyengine
"AndroidSensorsJoystick");
List<Sensor> availSensors = sensorManager.getSensorList(Sensor.TYPE_ALL);
for (Sensor sensor: availSensors) {
logger.log(Level.FINE, "{0} Sensor is available, Type: {1}, Vendor: {2}, Version: {3}",
代码示例来源:origin: stackoverflow.com
SensorManager mgr = (SensorManager) getSystemService(SENSOR_SERVICE);
List<Sensor> sensors = mgr.getSensorList(Sensor.TYPE_ALL);
for (Sensor sensor : sensors) {
Log.d("Sensors", "" + sensor.getName());
}
代码示例来源:origin: doggycoder/AndroidOpenGLDemo
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.glview);
mSensorManager=(SensorManager)getSystemService(Context.SENSOR_SERVICE);
List<Sensor> sensors=mSensorManager.getSensorList(Sensor.TYPE_ALL);
//todo 判断是否存在rotation vector sensor
mRotation=mSensorManager.getDefaultSensor(Sensor.TYPE_ROTATION_VECTOR);
mGLView=(GLSurfaceView) findViewById(R.id.mGLView);
mGLView.setEGLContextClientVersion(2);
mGLView.setRenderer(this);
mGLView.setRenderMode(GLSurfaceView.RENDERMODE_CONTINUOUSLY);
mSkySphere=new SkySphere(this.getApplicationContext(),"vr/360sp.jpg");
}
代码示例来源:origin: stackoverflow.com
class MySensorManagerWrapper implements MySensorManager {
SensorManager mSensorManager;
MySensorManagerWrapper(SensorManager sensorManager) {
super();
mSensorManager = sensorManager;
}
List<Sensor> getSensorList(int type) {
return mSensorManager.getSensorList(type_;
}
... // All the methods you have in your MySensorManager interface will need to be defined here - just call the mSensorManager object like in getSensorList()
}
代码示例来源:origin: stackoverflow.com
SensorManager manager = (SensorManager) getSystemService(SENSOR_SERVICE);
if (manager.getSensorList(Sensor.TYPE_ALL).isEmpty()) {
// running on an emulator
} else {
// running on a device
}
代码示例来源:origin: stackoverflow.com
SensorManager manager = (SensorManager) context
.getSystemService(Context.SENSOR_SERVICE);
if (manager.getSensorList(Sensor.TYPE_ACCELEROMETER).size() != 0) {
Sensor accelerometer = manager.getSensorList(Sensor.TYPE_ACCELEROMETER).get(0);
manager.registerListener(this, accelerometer, SensorManager.SENSOR_DELAY_GAME);
}
代码示例来源:origin: stackoverflow.com
SensorManager sm = (SensorManager) getSystemService(Context.SENSOR_SERVICE);
if(sm.getSensorList(Sensor.TYPE_GYROSCOPE).size() != 0)
{
Sensor s = sm.getSensorList(Sensor.TYPE_GYROSCOPE).get(0);
sm.registerListener(this, s, SensorManager.SENSOR_DELAY_GAME);
}
代码示例来源:origin: stackoverflow.com
SensorManager sensorManager = (SensorManager) context.getSystemService(Context.SENSOR_SERVICE);
Sensor sensor;
List<Sensor> sensors = sensorManager.getSensorList(
Sensor.TYPE_ORIENTATION);
if (sensors.size() > 0) {
sensor = sensors.get(0);
sensorManager.registerListener(
sensorEventListener, sensor,
SensorManager.SENSOR_DELAY_NORMAL);
} else {
//notify the user that there's no orientation sensor
}
代码示例来源:origin: stackoverflow.com
SensorManager manager;
Sensor accelerometer;
Activity foo;
public Accelero(Activity foo) {
this.foo = foo;
manager = (SensorManager) this.foo.getSystemService(Context.SENSOR_SERVICE);
accelerometer = manager.getSensorList(Sensor.TYPE_ACCELEROMETER).get(0);
manager.registerListener(this, accelerometer, SensorManager.SENSOR_DELAY_GAME);
}
代码示例来源:origin: stackoverflow.com
SensorManager sm = (SensorManager) getSystemService(SENSOR_SERVICE);
List<Sensor> list = sm.getSensorList(Sensor.TYPE_ALL);
for(Sensor s : list) {
Log.d("SENSORS", s.getName());
}
代码示例来源:origin: stackoverflow.com
public void printAllSensors() {
PackageManager manager = getPackageManager();
SensorManager sensorMngr = (SensorManager) getSystemService(Context.SENSOR_SERVICE);
List<Sensor> sensors = sensorMngr.getSensorList(Sensor.TYPE_ALL);
for (Sensor sensor : sensors) {
// debug or print the follwoing
sensor.getName();
}
}
代码示例来源:origin: kofigyan/Thermometer
private void attachToSensor() {
SensorManager sensorManager = getSensorManager();
List<Sensor> sensors = sensorManager.getSensorList(Sensor.TYPE_AMBIENT_TEMPERATURE);
if (sensors.size() > 0) {
Sensor sensor = sensors.get(0);
sensorManager.registerListener(this, sensor, SensorManager.SENSOR_DELAY_FASTEST, handler);
} else {
Toast.makeText(getContext(), "No Temperature Sensor Found", Toast.LENGTH_LONG).show();
}
}
代码示例来源:origin: IanDarwin/Android-Cookbook-Examples
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
mFace = (TextView) findViewById(R.id.faceTextView);
SensorManager sensorManager = (SensorManager) getSystemService(Context.SENSOR_SERVICE);
List<android.hardware.Sensor> sensorList =
sensorManager.getSensorList(Sensor.TYPE_ACCELEROMETER);
sensorManager.registerListener(accelerometerListener, sensorList.get(0), 0, null);
}
内容来源于网络,如有侵权,请联系作者删除!