हमारा सुझाव है कि 27 मार्च, 2025 से AOSP को बनाने और उसमें योगदान देने के लिए, aosp-main
के बजाय android-latest-release
का इस्तेमाल करें. ज़्यादा जानकारी के लिए, AOSP में हुए बदलाव लेख पढ़ें.
सेंसर
संग्रह की मदद से व्यवस्थित रहें
अपनी प्राथमिकताओं के आधार पर, कॉन्टेंट को सेव करें और कैटगरी में बांटें.
Android सेंसर, ऐप्लिकेशन को मोबाइल डिवाइस के फ़िज़िकल सेंसर का ऐक्सेस देते हैं. ये डेटा देने वाले वर्चुअल डिवाइस होते हैं. इनकी जानकारी, सेंसर हार्डवेयर ऐब्स्ट्रैक्शन लेयर (एचएएल) sensors.h से मिलती है.
Android सेंसर क्या होते हैं?
Android सेंसर, वर्चुअल डिवाइस होते हैं. ये डिवाइस, फ़िज़िकल सेंसर के सेट से मिलने वाला डेटा उपलब्ध कराते हैं. जैसे, एक्सलरोमीटर, जाइरोस्कोप, मैग्नेटोमीटर, बैरोमीटर, नमी, दबाव, रोशनी, प्रॉक्सिमिटी, और हृदय की गति के सेंसर.
डेटा देने वाले फ़िज़िकल डिवाइसों की सूची में कैमरा, फ़िंगरप्रिंट सेंसर, माइक्रोफ़ोन, और टच स्क्रीन शामिल नहीं हैं. इन डिवाइसों के पास, डेटा भेजने का अपना तरीका होता है. इन डिवाइसों को अलग-अलग इसलिए रखा गया है, क्योंकि इनमें डेटा भेजने की सुविधाएं अलग-अलग होती हैं. हालांकि, आम तौर पर Android सेंसर कम बैंडविड्थ का डेटा देते हैं. उदाहरण के लिए, ऐक्सेलेरोमीटर के लिए “100hz x 3 चैनल” बनाम कैमरे के लिए “25hz x 8 एमपी x 3 चैनल” या माइक्रोफ़ोन के लिए “44kHz x 1 चैनल”.
Android यह तय नहीं करता कि अलग-अलग फ़िज़िकल सेंसर, चिप पर सिस्टम (SoC) से कैसे कनेक्ट होते हैं.
- अक्सर, सेंसर चिप को सेंसर हब के ज़रिए SoC से कनेक्ट किया जाता है. इससे, कम बिजली की खपत करके डेटा को मॉनिटर और प्रोसेस किया जा सकता है.
- आम तौर पर, ट्रांसपोर्ट मैकेनिज्म के तौर पर इंटर-इंटिग्रेटेड सर्किट (I2C) या सीरियल पेरिफ़रल इंटरफ़ेस (SPI) का इस्तेमाल किया जाता है.
- बिजली की खपत कम करने के लिए, कुछ आर्किटेक्चर हैरारकी वाले होते हैं. इनमें, ऐप्लिकेशन के हिसाब से इंटिग्रेटेड सर्किट (एएसआईसी - जैसे कि ऐक्सीलेरोमीटर चिप पर मोशन डिटेक्शन) में कुछ कम प्रोसेसिंग की जाती है. ज़्यादा प्रोसेसिंग, माइक्रोकंट्रोलर में की जाती है. जैसे, सेंसर हब में कदमों का पता लगाना.
- डिवाइस बनाने वाली कंपनी के पास, सटीक जानकारी, बैटरी, कीमत, और पैकेज के साइज़ के आधार पर कोई आर्किटेक्चर चुनने का विकल्प होता है. ज़्यादा जानकारी के लिए, सेंसर स्टैक देखें.
- बैच करने की सुविधाएं, बेहतर ऑप्टिमाइज़ेशन के लिए अहम हैं. ज़्यादा जानकारी के लिए, एक साथ कई प्रॉडक्ट अपलोड करना देखें.
हर Android सेंसर का एक “टाइप” होता है. इससे पता चलता है कि सेंसर कैसे काम करता है और वह कौनसा डेटा उपलब्ध कराता है.
- Android के आधिकारिक सेंसर के टाइप, sensors.h में SENSOR_TYPE_… के नाम से तय किए गए हैं
- ज़्यादातर सेंसर का एक आधिकारिक टाइप होता है.
- इन टाइप के बारे में Android SDK में बताया गया है.
- इस तरह के सेंसर के व्यवहार की जांच, Android के साथ काम करने से जुड़े टेस्ट सुइट (CTS) में की जाती है.
- अगर कोई मैन्युफ़ैक्चरर, Android डिवाइस में किसी नए तरह के सेंसर को इंटिग्रेट करता है, तो वह उसे रेफ़र करने के लिए, कुछ समय के लिए अपने हिसाब से टाइप तय कर सकता है.
- इन टाइप के बारे में कोई दस्तावेज़ नहीं है. इसलिए, ऐप्लिकेशन डेवलपर इनका इस्तेमाल शायद ही करें. ऐसा इसलिए, क्योंकि उन्हें इनके बारे में पता नहीं है या उन्हें पता है कि ये बहुत कम मौजूद होते हैं (सिर्फ़ इस मैन्युफ़ैक्चरर के कुछ डिवाइसों पर).
- इनकी जांच, सीटीएस नहीं करता.
- जब Android इस तरह के सेंसर के लिए आधिकारिक सेंसर टाइप तय कर देगा, तब मैन्युफ़ैक्चरर को अपने सेंसर के लिए, अस्थायी तौर पर तय किए गए टाइप का इस्तेमाल बंद करना होगा. इसके बजाय, उन्हें आधिकारिक टाइप का इस्तेमाल करना होगा. इससे, ज़्यादा ऐप्लिकेशन डेवलपर, सेंसर का इस्तेमाल कर पाएंगे.
- डिवाइस पर मौजूद सभी सेंसर की सूची, एचएएल लागू करने की प्रोसेस के ज़रिए दी जाती है.
- एक ही तरह के कई सेंसर हो सकते हैं. उदाहरण के लिए, दो
प्रॉक्सिमिटी सेंसर या दो एक्सलरोमीटर.
- ज़्यादातर ऐप्लिकेशन, किसी एक तरह के सिर्फ़ एक सेंसर का अनुरोध करते हैं. उदाहरण के लिए, डिफ़ॉल्ट ऐक्सीलेरोमीटर का अनुरोध करने वाले ऐप्लिकेशन को सूची में पहला ऐक्सीलेरोमीटर मिलेगा.
- सेंसर को अक्सर वॉकी-अप और
नॉन-वॉकी-अप
पेयर के हिसाब से तय किया जाता है. दोनों सेंसर एक ही टाइप के होते हैं, लेकिन वॉकी-अप की सुविधा के हिसाब से अलग-अलग होते हैं.
Android सेंसर, सेंसर इवेंट की सीरीज़ के तौर पर डेटा उपलब्ध कराते हैं.
हर इवेंट में ये चीज़ें शामिल होती हैं:
रिपोर्ट किए गए डेटा का विश्लेषण, सेंसर के टाइप पर निर्भर करता है. हर तरह के सेंसर के लिए किस तरह का डेटा रिपोर्ट किया जाता है, इस बारे में जानने के लिए सेंसर टाइप की परिभाषाएं देखें.
मौजूदा दस्तावेज़
डेवलपर के लिए
- खास जानकारी
- SDK टूल का रेफ़रंस
- Stack Overflow और ट्यूटोरियल वाली वेबसाइटें
- सेंसर के दस्तावेज़ कभी-कभी उपलब्ध नहीं होते थे. इसलिए, डेवलपर ने जवाब पाने के लिए, सवाल-जवाब वाली वेबसाइटों जैसे कि Stack Overflow का इस्तेमाल किया.
- ट्यूटोरियल वाली कुछ वेबसाइटें भी मौजूद हैं, लेकिन उनमें बैचिंग, अहम मोशन, और गेम रोटेशन वेक्टर जैसी नई सुविधाओं के बारे में नहीं बताया गया है.
- यहां दिए गए जवाब हमेशा सही नहीं होते. साथ ही, इससे यह भी पता चलता है कि आपको और कौनसे दस्तावेज़ सबमिट करने होंगे.
मैन्युफ़ैक्चरर के लिए
- खास जानकारी
- यह सेंसर
पेज और इसके सब-पेज.
- हार्डवेयर ऐब्स्ट्रैक्शन लेयर (एचएएल)
- Android सीडीडी (कंपैटबिलिटी डेफ़िनिशन डॉक्यूमेंट)
- /compatibility/android-cdd.pdf
- सेंसर से जुड़े सेक्शन देखें.
- सीडीडी की शर्तें आसान हैं. इसलिए, अच्छी क्वालिटी के सेंसर उपलब्ध कराने के लिए, सीडीडी की शर्तों को पूरा करना ही काफ़ी नहीं है.
इस पेज पर मौजूद कॉन्टेंट और कोड सैंपल कॉन्टेंट के लाइसेंस में बताए गए लाइसेंस के हिसाब से हैं. Java और OpenJDK, Oracle और/या इससे जुड़ी हुई कंपनियों के ट्रेडमार्क या रजिस्टर किए हुए ट्रेडमार्क हैं.
आखिरी बार 2025-07-27 (UTC) को अपडेट किया गया.
[[["समझने में आसान है","easyToUnderstand","thumb-up"],["मेरी समस्या हल हो गई","solvedMyProblem","thumb-up"],["अन्य","otherUp","thumb-up"]],[["वह जानकारी मौजूद नहीं है जो मुझे चाहिए","missingTheInformationINeed","thumb-down"],["बहुत मुश्किल है / बहुत सारे चरण हैं","tooComplicatedTooManySteps","thumb-down"],["पुराना","outOfDate","thumb-down"],["अनुवाद से जुड़ी समस्या","translationIssue","thumb-down"],["सैंपल / कोड से जुड़ी समस्या","samplesCodeIssue","thumb-down"],["अन्य","otherDown","thumb-down"]],["आखिरी बार 2025-07-27 (UTC) को अपडेट किया गया."],[],[],null,["# Sensors\n\nAndroid sensors give applications access to a mobile device's underlying\nphysical sensors. They are data-providing virtual devices defined by [sensors.h](https://android.googlesource.com/platform/hardware/libhardware/+/android16-release/include/hardware/sensors.h), the sensor Hardware Abstraction Layer (HAL).\n\nWhat are Android sensors?\n-------------------------\n\nAndroid sensors are virtual devices that provide data coming from a set of\nphysical sensors: accelerometers, gyroscopes, magnetometers, barometer, humidity,\npressure, light, proximity and heart rate sensors.\n\nNot included in the list of physical devices providing data are camera,\nfingerprint sensor, microphone, and touch screen. These devices have their own\nreporting mechanism; the separation is arbitrary, but in general, Android sensors\nprovide lower bandwidth data. For example, \"100hz x 3 channels\" for an\naccelerometer versus \"25hz x 8 MP x 3 channels\" for a camera or \"44kHz x 1\nchannel\" for a microphone.\n\nAndroid does not define how the different physical sensors are connected\nto the system on chip (SoC).\n\n- Often, sensor chips are connected to the SoC through a [sensor hub](/docs/core/interaction/sensors/sensor-stack#sensor_hub), allowing some low-power monitoring and processing of the data.\n- Often, Inter-Integrated Circuit (I2C) or Serial Peripheral Interface (SPI) is used as the transport mechanism.\n- To reduce power consumption, some architectures are hierarchical, with some minimal processing being done in the application-specific integrated circuit (ASIC - like motion detection on the accelerometer chip), and more is done in a microcontroller (like step detection in a sensor hub).\n- It is up to the device manufacturer to choose an architecture based on accuracy, power, price and package-size characteristics. See [Sensor stack](/docs/core/interaction/sensors/sensor-stack) for more information.\n- Batching capabilities are an important consideration for power optimization. See [Batching](/docs/core/interaction/sensors/batching) for more information.\n\nEach Android sensor has a \"type\" representing how the sensor behaves and\nwhat data it provides.\n\n- The official Android [Sensor\n types](/docs/core/interaction/sensors/sensor-types) are defined in [sensors.h](https://android.googlesource.com/platform/hardware/libhardware/+/android16-release/include/hardware/sensors.h) under the names SENSOR_TYPE_...\n - The vast majority of sensors have an official sensor type.\n - Those types are documented in the Android SDK.\n - Behavior of sensors with those types are tested in the Android Compatibility Test Suite (CTS).\n- If a manufacturer integrates a new kind of sensor on an Android device, the manufacturer can define its own temporary type to refer to it.\n - Those types are undocumented, so application developers are unlikely to use them, either because they don't know about them, or know that they are rarely present (only on some devices from this specific manufacturer).\n - They are not tested by CTS.\n - Once Android defines an official sensor type for this kind of sensor, manufacturers must stop using their own temporary type and use the official type instead. This way, the sensor will be used by more application developers.\n- The list of all sensors present on the device is reported by the HAL implementation.\n - There can be several sensors of the same type. For example, two proximity sensors or two accelerometers.\n - The vast majority of applications request only a single sensor of a given type. For example, an application requesting the default accelerometer will get the first accelerometer in the list.\n - Sensors are often defined by [wake-up](/docs/core/interaction/sensors/suspend-mode#wake-up_sensors) and [non-wake-up](/docs/core/interaction/sensors/suspend-mode#non-wake-up_sensors) pairs, both sensors sharing the same type, but differing by their wake-up characteristic.\n\nAndroid sensors provide data as a series of sensor events.\n\nEach [event](/docs/core/interaction/sensors/hal-interface#sensors_event_t)\ncontains:\n\n- a handle to the sensor that generated it\n- the timestamp at which the event was detected or measured, based on [`SystemClock.elapsedRealtimeNanos()`](https://developer.android.com/reference/android/os/SystemClock#elapsedRealtimeNanos())\n- and some data\n\nThe interpretation of the reported data depends on the sensor type. See\nthe [sensor type](/docs/core/interaction/sensors/sensor-types)\ndefinitions for details on what data is reported for each sensor type.\n\nExisting documentation\n----------------------\n\n### Targeted at developers\n\n- Overview\n - \u003chttps://developer.android.com/guide/topics/sensors/sensors_overview.html\u003e\n- SDK reference\n - \u003chttps://developer.android.com/reference/android/hardware/SensorManager\u003e\n - \u003chttps://developer.android.com/reference/android/hardware/SensorEventListener\u003e\n - \u003chttps://developer.android.com/reference/android/hardware/SensorEvent\u003e\n - \u003chttps://developer.android.com/reference/android/hardware/Sensor\u003e\n- Stack Overflow and tutorial websites\n - Because sensors documentation was sometimes lacking, developers resorted to Q\\&A websites like Stack Overflow to find answers.\n - Some tutorial websites exist as well, but do not cover the latest features like batching, significant motion and game rotation vectors.\n - The answers over there are not always right, and show where more documentation is needed.\n\n### Targeted at manufacturers\n\n- Overview\n - This [Sensors](/docs/core/interaction/sensors) page and its sub-pages.\n- Hardware abstraction layer (HAL)\n - [/platform/hardware/libhardware/+/android16-release/include/hardware/sensors.h](https://android.googlesource.com/platform/hardware/libhardware/+/android16-release/include/hardware/sensors.h)\n - Also known as \"sensors.h\"\n - The source of truth. First document to be updated when new features are developed.\n- Android CDD (Compatibility Definition Document)\n - [/compatibility/android-cdd.pdf](/static/docs/compatibility/android-cdd.pdf)\n - See sections relative to sensors.\n - The CDD is lenient, so satisfying the CDD requirements is not enough to ensure high quality sensors."]]