0% found this document useful (0 votes)
2 views

Android_Sensor_MSBT_Example

The document explains the different types of sensors available in Android, including Motion Sensors (e.g., Accelerometer), Environmental Sensors (e.g., Temperature, Humidity), and Position Sensors (e.g., Proximity Sensor). It also describes a demo application that simulates Temperature and Humidity Sensor values, displaying them upon button click. The example includes Java code for functionality and XML layout for the user interface.

Uploaded by

omkargujar911
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views

Android_Sensor_MSBT_Example

The document explains the different types of sensors available in Android, including Motion Sensors (e.g., Accelerometer), Environmental Sensors (e.g., Temperature, Humidity), and Position Sensors (e.g., Proximity Sensor). It also describes a demo application that simulates Temperature and Humidity Sensor values, displaying them upon button click. The example includes Java code for functionality and XML layout for the user interface.

Uploaded by

omkargujar911
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

Android Sensors - MSBTE Exam Answer

Q. Explain different types of available sensors in Android with example.

Android provides built-in support for various sensors to detect physical and environmental changes.

These sensors help create interactive and smart applications.

Types of Android Sensors:

1. Motion Sensors

Detect motion or acceleration.

Examples: Accelerometer, Gyroscope, Gravity Sensor

2. Environmental Sensors

Detect data from the environment.

Examples: Temperature, Humidity, Light Sensor

3. Position Sensors

Measure physical position or orientation.

Examples: Proximity Sensor, Magnetometer (Compass)

Example: Environmental Sensor Demo App

I created a simple Android application to simulate Temperature and Humidity Sensor values.

When the "Load Sensor Data" button is clicked, it displays:

- Temperature: 24.5°C
- Humidity: 55.8%

Java (MainActivity.java):

// Simulates temperature and humidity values on button click

double temperature = 24.5;

double humidity = 55.8;

temperatureText.setText("Temperature: " + temperature + " °C");

humidityText.setText("Humidity: " + humidity + " %");

XML Layout (activity_main.xml):

<TextView android:id="@+id/temperatureText" ... />

<TextView android:id="@+id/humidityText" ... />

<Button android:id="@+id/loadButton" ... />

Viva Tip:

You can say:

"This example simulates environmental sensors in Android. I used a simple layout with button and

text, and displayed the sensor values when button is clicked."

You might also like