Presentation is loading. Please wait.

Presentation is loading. Please wait.

Android Intents & Sensors

Similar presentations


Presentation on theme: "Android Intents & Sensors"— Presentation transcript:

1 Android Intents & Sensors
CSE651C, B.Ramamurthy 4/8/2019

2 References CSE651C, B.Ramamurthy 4/8/2019

3 Intents What are intents?
“An Intent provides a facility for performing late runtime binding between the code in different applications. Its most significant use is in the launching of activities, where it can be thought of as the glue between activities. It is basically a passive data structure holding an abstract description of an action to be performed.” Example it bridges the need for communication between apps: Android App1 Android App1 Intent CSE651C, B.Ramamurthy 4/8/2019

4 Email is a common intent
See the code below for intent: Intent intent = new Intent(Intent.ACTION_SENDTO); intent.setType("text/plain"); intent.putExtra(Intent.EXTRA_SUBJECT, "Subject of "); intent.putExtra(Intent.EXTRA_TEXT, "Body of "); intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); CSE651C, B.Ramamurthy 4/8/2019

5 Use Cases “An Intent is a messaging object you can use to request an action from another app component. Although intents facilitate communication between components in several ways, there are three fundamental use cases:” Starting an Activity..like a timer within an app Starting an underlying Service.. Scheduler service Delivering a broadcast: push a message to a group. CSE651C, B.Ramamurthy 4/8/2019

6 Lets look at an example Simple App, that writes the text view to logs, but it can also send to an specified. CSE651C, B.Ramamurthy 4/8/2019

7 Sensors Android supports a broad category of sensors:
Motion sensors: accelerometers, gravity sensors, gyroscopes, and rotational vector sensors. Environmental sensors: for air temperature and pressure, illumination, and humidity Position sensors: orientation sensors and magnetometers. CSE651C, B.Ramamurthy 4/8/2019

8 Sensor Framework Sensor manager Sensor Sensor event 4/8/2019
CSE651C, B.Ramamurthy 4/8/2019

9 Example code: Accelerometer
Lets explore the code and activity for an accelerometer sensor The code is available in ublearns. Download it and open it Lets review the code and execute the example If you upload it to your Android phone you can actually see it working. CSE651C, B.Ramamurthy 4/8/2019

10 Summary We looked at Android Intent and Android Sensors framework.
These are very powerful features of Android that make it a comprehensive tool/device than just a phone Get deeper into these two topics for developing apps and also for adding other Intents and sensors. Automotive domain is a fertile area for exploration in Intents and sensors. CSE651C, B.Ramamurthy 4/8/2019


Download ppt "Android Intents & Sensors"

Similar presentations


Ads by Google