Jimmy's papa最近查一下MOTO XOOM官網的規格說明,有關Sensor的部份官網提到有
Proximity(近距離),
ambient light(環境光),
barometer(氣壓計),
gyroscope(陀螺儀)
不過好像跟在其他的平板討論區提到的有點不大一樣,印象中有加速感應器(acceleration)卻沒有距離感應器(Proximity)
為求真相,Jimmy's papa只好捲起袖子動手寫程式囉!!!最後程式跑出的詳細感應器列表有一堆
KXTF9 3-axis Accelerometer,
Ambient Light sensor,
AK8975 3-axis Magnetic field sensor,
AK8975 Orientation sensor,
BMP085 Pressure sensor(這應該是氣壓計),
L3G4200D Gyroscope sensor,
Gravity Sensor,
Linear Acceleration Sensor,
Rotation Vector Sensor
寄件者 scratchlab |
package com.jimmyscratchlab.androidsensorlist;
import java.util.ArrayList;
import java.util.List;
import android.app.ListActivity;
import android.content.Context;
import android.hardware.Sensor;
import android.hardware.SensorManager;
import android.util.Log;
import android.widget.ArrayAdapter;
import android.os.Bundle;
public class AndroidSensorListActivity extends ListActivity {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
SensorManager sensorManager
= (SensorManager)getSystemService(Context.SENSOR_SERVICE);
List<Sensor> sensorList = sensorManager.getSensorList(Sensor.TYPE_ALL);
List<String> sensorTypeList = new ArrayList<String>();
for(int i=0; i<sensorList.size(); i++){
sensorTypeList.add(sensorList.get(i).getName());
}
setListAdapter(new ArrayAdapter<String>(this,android.R.layout.simple_list_item_1,
sensorTypeList)); //Jimmy's papa查過了,simple_list_item_1是內建的
//getListView().setTextFilterEnabled(true);
Log.i("SensorTypeList", sensorTypeList.toString());
}
}
沒有留言:
張貼留言