本文整理匯總了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);
}