传感器和位置信息简介
使用集合让一切井井有条
根据您的偏好保存内容并对其进行分类。
借助 Android 设备配备的传感器,您可以为用户提供有关其周围环境的背景信息,包括位置感知、运动、位置和物理环境的质量。
如需为用户提供更丰富、更特定于情境的体验,请使用能够利用以下类型的传感器的 Android API:
使用 GPS,通过自动位置信息跟踪、错误街道侧检测、地理围栏、运动状态识别等功能,为您的应用添加位置信息感知功能。
使用移动传感器来测量沿三个轴的加速力和旋转力。这个类别包括加速度计、重力传感器、陀螺仪和旋转矢量传感器。
使用位置传感器测量设备的实际位置。这个类别包括方向传感器和磁力计。
使用环境传感器测量各种环境参数,如环境气温和压力、照度和湿度。
这个类别包括气压计、光度计和温度计。
视频
本页面上的内容和代码示例受内容许可部分所述许可的限制。Java 和 OpenJDK 是 Oracle 和/或其关联公司的注册商标。
最后更新时间 (UTC):2025-07-26。
[null,null,["最后更新时间 (UTC):2025-07-26。"],[],[],null,["# About sensors and location\n\nAndroid-powered devices have sensors that let you provide users with contextual\ninformation about their surroundings, including location awareness, motion,\nposition, and qualities of the physical environment.\n\nTo provide a much richer, more more context-specific experience for users, use\nAndroid APIs that take advantage of the following types of sensors:\n\n- Use [GPS](/develop/sensors-and-location/location) to add location awareness to your app with automated location\n tracking, wrong-side-of-the-street detection, geofencing, activity\n recognition, and more.\n\n- Use [motion sensors](/develop/sensors-and-location/sensors/sensors_motion) to measure acceleration forces and rotational forces\n along three axes. This category includes accelerometers, gravity sensors,\n gyroscopes, and rotational vector sensors.\n\n- Use [position sensors](/develop/sensors-and-location/sensors/sensors_position) to measure the physical position of a device. This\n category includes orientation sensors and magnetometers.\n\n- Use [environmental sensors](/develop/sensors-and-location/sensors/sensors_environment) to measure various environmental parameters,\n such as ambient air temperature and pressure, illumination, and humidity.\n This category includes barometers, photometers, and thermometers.\n\nVideos\n------"]]