出于设计原因,我必须使用扩展对话框将 Android 传感器特定代码实现到类中。例如,
public class ImplEndUserGUI extends Dialog implements IEndUserGUI {
public void onCreate(Bundle savedInstanceState) {
setContentView(R.layout.enduserguilayout);
super.onCreate(savedInstanceState);
//TODO : I have to write Android specific code here....
SensorManager sensorManager =
(SensorManager) getSystemService(Context.SENSOR_SERVICE);
Sensor lightSensor =
sensorManager.getDefaultSensor(Sensor.TYPE_LIGHT);
.....
}
}
现在,问题是(以我对 Android 编程的有限知识),Android 不允许我getSystemService(Context.SENSOR_SERVICE)
使用ImplEndUserGUI
extends Dialog
. 您能否建议我使用extends Dialog
.