当前位置: 首页>>代码示例>>Java>>正文


Java SensorManager.getSensorList方法代码示例

本文整理汇总了Java中android.hardware.SensorManager.getSensorList方法的典型用法代码示例。如果您正苦于以下问题:Java SensorManager.getSensorList方法的具体用法?Java SensorManager.getSensorList怎么用?Java SensorManager.getSensorList使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在android.hardware.SensorManager的用法示例。


在下文中一共展示了SensorManager.getSensorList方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: A

import android.hardware.SensorManager; //导入方法依赖的package包/类
public static String A(Context context) {
    try {
        SensorManager sensorManager = (SensorManager) context.getSystemService("sensor");
        if (sensorManager != null) {
            List sensorList = sensorManager.getSensorList(-1);
            if (sensorList != null) {
                StringBuilder stringBuilder = new StringBuilder();
                for (int i = 0; i < sensorList.size(); i++) {
                    stringBuilder.append(((Sensor) sensorList.get(i)).getType());
                    if (i != sensorList.size() - 1) {
                        stringBuilder.append(",");
                    }
                }
                return stringBuilder.toString();
            }
        }
    } catch (Object th) {
        f.e(th);
    }
    return "";
}
 
开发者ID:JackChan1999,项目名称:boohee_v5.6,代码行数:22,代码来源:k.java

示例2: M

import android.hardware.SensorManager; //导入方法依赖的package包/类
public static String M(Context context) {
    if (e(cE)) {
        return cE;
    }
    try {
        SensorManager sensorManager = (SensorManager) context.getSystemService("sensor");
        if (sensorManager != null) {
            List sensorList = sensorManager.getSensorList(-1);
            if (sensorList != null) {
                StringBuilder stringBuilder = new StringBuilder(sensorList.size() * 10);
                for (int i = 0; i < sensorList.size(); i++) {
                    stringBuilder.append(((Sensor) sensorList.get(i)).getType());
                    if (i != sensorList.size() - 1) {
                        stringBuilder.append(",");
                    }
                }
                cE = stringBuilder.toString();
            }
        }
    } catch (Throwable th) {
        cT.b(th);
    }
    return cE;
}
 
开发者ID:JackChan1999,项目名称:boohee_v5.6,代码行数:25,代码来源:l.java

示例3: getSensorDigest

import android.hardware.SensorManager; //导入方法依赖的package包/类
public String getSensorDigest(Context context) {
    if (context == null) {
        return null;
    }
    try {
        String sha1ByString;
        SensorManager sensorManager = (SensorManager) context.getSystemService("sensor");
        if (sensorManager != null) {
            List<Sensor> sensorList = sensorManager.getSensorList(-1);
            if (sensorList != null && sensorList.size() > 0) {
                StringBuilder stringBuilder = new StringBuilder();
                for (Sensor sensor : sensorList) {
                    stringBuilder.append(sensor.getName());
                    stringBuilder.append(sensor.getVersion());
                    stringBuilder.append(sensor.getVendor());
                }
                sha1ByString = CommonUtils.sha1ByString(stringBuilder.toString());
                return sha1ByString;
            }
        }
        sha1ByString = null;
        return sha1ByString;
    } catch (Exception e) {
        return null;
    }
}
 
开发者ID:JackChan1999,项目名称:boohee_v5.6,代码行数:27,代码来源:DeviceInfo.java

示例4: onCreate

import android.hardware.SensorManager; //导入方法依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    sensorManager = (SensorManager) getSystemService(Context.SENSOR_SERVICE);

    setContentView(R.layout.activity_sensor_single_value);
    sensorName = (TextView) findViewById(R.id.sensorName);
    singleValue = (TextView) findViewById(R.id.singleValue);

    Intent i = getIntent();
    String sName = i.getStringExtra(SensorListActivity.SENSOR_NAME);
    if (sName == null) {
        finish();
    }

    int sType = i.getIntExtra(SensorListActivity.SENSOR_TYPE,Sensor.TYPE_ALL);

    for (Sensor s : sensorManager.getSensorList(sType)) {
        if (s.getName().equals(sName)) {
            sensor = s;
        }
    }

    if (sensor == null) {
        finish();
    }
    else {
        sensorName.setText(sensor.getName());
    }
}
 
开发者ID:if710,项目名称:2017.2-codigo,代码行数:32,代码来源:SensorSingleValueActivity.java

示例5: onCreate

import android.hardware.SensorManager; //导入方法依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    sensorManager = (SensorManager) getSystemService(Context.SENSOR_SERVICE);

    setContentView(R.layout.activity_sensor_xyz);
    sensorName = (TextView) findViewById(R.id.sensorName);
    xValue = (TextView) findViewById(R.id.xValue);
    yValue = (TextView) findViewById(R.id.yValue);
    zValue = (TextView) findViewById(R.id.zValue);

    Intent i = getIntent();
    String sName = i.getStringExtra(SensorListActivity.SENSOR_NAME);
    if (sName == null) {
        finish();
    }

    int sType = i.getIntExtra(SensorListActivity.SENSOR_TYPE,Sensor.TYPE_ALL);

    for (Sensor s : sensorManager.getSensorList(sType)) {
        if (s.getName().equals(sName)) {
            sensor = s;
        }
    }

    if (sensor == null) {
        finish();
    }
    else {
        sensorName.setText(sensor.getName());
    }
}
 
开发者ID:if710,项目名称:2017.2-codigo,代码行数:34,代码来源:SensorXYZActivity.java

示例6: onCreate

import android.hardware.SensorManager; //导入方法依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    sensorManager = (SensorManager) getSystemService(Context.SENSOR_SERVICE);

    //assim como em LocationManager a gente pega um tipo de provider (GPS_PROVIDER)
    //com sensores, não há APIs dedicadas para sensores, usamos o SensorManager
    //os sensores são identificados por nomes (TYPE_LINEAR_ACCELERATION)

    //existem sensores e tipos de sensores
    //abaixo, estamos pedindo todos os sensores, de todos os tipos
    List<Sensor> allSensors = new ArrayList<>(sensorManager.getSensorList(Sensor.TYPE_ALL));
    List<Sensor> sensors = new ArrayList<>();

    //removendo trigger sensors, que entregam apenas uma única leitura
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
        for (Sensor s : allSensors) {
            boolean triggerSensor = s.getType() == Sensor.TYPE_SIGNIFICANT_MOTION ||
                    s.getType() == Sensor.TYPE_STEP_COUNTER ||
                    s.getType() == Sensor.TYPE_STEP_DETECTOR;

            if (!triggerSensor) {
                sensors.add(s);
            }
        }
    }
    else {
        sensors = allSensors;
    }

    adapter=new ArrayAdapter<>(this, android.R.layout.simple_list_item_1, sensors);
    setListAdapter(adapter);
}
 
开发者ID:if710,项目名称:2017.2-codigo,代码行数:35,代码来源:SensorListActivity.java

示例7: hasLightSensor

import android.hardware.SensorManager; //导入方法依赖的package包/类
public static boolean hasLightSensor(Context context) {
	boolean supported = false;
	SensorManager sensorService = (SensorManager) context.getSystemService(Context.SENSOR_SERVICE);
	if (sensorService != null) {
		List<Sensor> lightSensors = sensorService.getSensorList(Sensor.TYPE_LIGHT);
		supported = lightSensors != null && lightSensors.size() > 0;
	}
	return supported;
}
 
开发者ID:sdrausty,项目名称:buildAPKsApps,代码行数:10,代码来源:BrightnessPrefs.java

示例8: checkSensorAvailability

import android.hardware.SensorManager; //导入方法依赖的package包/类
private boolean checkSensorAvailability(SensorManager sensorManager, int type) {
    List<Sensor> sensors = sensorManager.getSensorList(type);
    return !(sensors == null || sensors.size() == 0);
}
 
开发者ID:WorldBank-Transport,项目名称:RoadLab-Pro,代码行数:5,代码来源:GravityAccelerometerDetector.java


注:本文中的android.hardware.SensorManager.getSensorList方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。