本文整理汇总了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 "";
}
示例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;
}
示例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;
}
}
示例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());
}
}
示例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());
}
}
示例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);
}
示例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;
}
示例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);
}