mad_lab_file[1]
mad_lab_file[1]
Report
On
Submitted to Submitted to
1
Introduction
The application is written in Kotlin and designed for Android devices. Its primary purpose is
to retrieve and display a list of all available hardware sensors, such as the accelerometer,
gyroscope, and proximity sensor. This application helps users understand the sensors their
device supports, which can be useful for testing or learning.
1. Package Declaration: Specifies that the app belongs to a group of code files in the
"com.example.devicesensors" package.
2. Imports:
o Tools to interact with device hardware (e.g., Sensor Manager and Sensor).
o The AppCompatActivity class, which helps manage activities in Android.
o TextView, used to display text on the screen.
3. MainActivity Class: This is the heart of the application. It:
o Sets up the layout when the app starts.
o Uses SensorManager to interact with hardware sensors.
o Displays sensor information on the screen using a TextView.
1. Setup:
o The app begins by initializing the activity when the user opens it.
o The user interface is linked to a layout file, which contains a TextView for
displaying the sensor list.
2. Initialize SensorManager:
o The code accesses Android's hardware system services using
getSystemService.
2
o A SensorManager object is created, which acts as the gateway to all hardware
sensors.
Execution Flow
Output
3
Applications and Benefits
Limitations
• Dependency on Layout:
o If the TextView in the layout is missing or misconfigured, the app will crash.
• Unfiltered Data:
o Displays raw sensor information, which may be overwhelming for non-
technical users.
4
Flowchart
5
Pseudocode
START
1. Initialize SensorManager:
a. Use getSystemService(Context.SENSOR_SERVICE) to retrieve SensorManager
instance.
3. Find TextView:
a. Use findViewById (R.id.tv) to locate the TextView in the layout.
END
6
Source code
7
Output
8
Conclusion
The app effectively demonstrates how to use Android’s SensorManager to interact with
hardware sensors. It’s simple and functional, making it a great starting point for developers.
With a few enhancements, it could become a comprehensive tool for sensor diagnostics and
learning.