让我们来看看SensorManager的代码
SensorManager框架层代码
@frameworks/base/core/java/android/hardware/SensorManager.java
public SensorManager(Looper mainLooper) {
mMainLooper = mainLooper; // 上面说了,这是Activity的Looper
synchronized(sListeners) {
if(!sSensorModuleInitialized) {
sSensorModuleInitialized = true;
nativeClassInit(); // 好像是调用本地方法初始化
sWindowManager = IWindowManager.Stub.asInterface(
ServiceManager.getService("window")); // 获得Windows服务,不管它
if (sWindowManager != null) {
// if it's null we're running in the system process
// which won't get the rotated values
try {
sRotation = sWindowManager.watchRotation(
北京同远天下创始人,专注于企业服务,企业系统解决方案,物联网,智慧社区,产品有众狐邮箱验证www.verify-mail.net,众狐微客服系统,著有《深入浅出嵌入式底层软件开发》北航出版社