You are previewing Learning Android Intents.
O'Reilly logo
Learning Android Intents

Book Description

If you already know at least the basics of Android, this is an opportunity to enhance your knowledge and acquire a deep understanding of Android Intents, allowing you to develop apps faster and more effectively.

In Detail

Android is an emerging technology with loads of apps in the Google Play Market. Till date, it is the biggest marvel in Smartphone technology, propelling a larger number of developers into Android application development. Intent is an essential part of any Android Application and no Android application is complete without using them. Features such as listening broadcasts, sending messages, sharing via social networks, notifications, hardware components including camera, sensors, Wi-Fi, and more, can be used in your applications by using Intents.

This practical guide focuses on using intents to make the best use of various features of Android platform. It is ideal for those developers who want to understand the backbone and the domain of Android Intents, its power, and the need for it inside an Android application. Practical, in-depth examples are used throughout the book, to help you understand the key concepts.

The book starts with introducing the very basic concepts of Android, and its various facts and figures such as different Android versions, their release dates, evolution of Android phones and so on. While covering the basic technical concepts, it proceeds from the easiest route of introducing Android Intents towards the more practical view of Android Intents in terms of components and features.

You will learn how to use different components and features such as transfer data between activities, invoke various features and components of Android, execute different in-built and custom-made services, use hardware and software components of Android device, and start Pending Intents & notifications. You will gain better theoretical knowledge of what is running behind the concepts of Android Intents, and practical knowledge of the mobile-efficient ways to perform a certain task using Android Intents.

Towards the end, you will have a clear vision and a practical grip on Android intents and its features. Learning Android Intents is a proper guide to give you the best knowledge of Intents.

What You Will Learn

  • Understand Android Intents and their importance in Android apps
  • Get to grips with the different types of Intents and their implementation
  • Discover data transfer methods in Android Intents along with their optimization and performance comparisons
  • Explore the implementation of Intents while invoking Android Features in an application.
  • Use Intent Filters and their sub-domains in order to perform various actions and sorting categories in Android Intents
  • Catch different events while working with Broadcast Receiver and perform various actions
  • Implement pending Intents and Intent Service, sending text to the Notification Panel, and much more
  • Downloading the example code for this book. You can download the example code files for all Packt books you have purchased from your account at If you purchased this book elsewhere, you can visit and register to have the files e-mailed directly to you.

    Table of Contents

    1. Learning Android Intents
      1. Table of Contents
      2. Learning Android Intents
      3. Credits
      4. About the Authors
      5. About the Reviewers
        1. Support files, eBooks, discount offers and more
          1. Why Subscribe?
          2. Free Access for Packt account holders
      7. Preface
        1. What this book covers
        2. What you need for this book
        3. Who this book is for
        4. Conventions
        5. Reader feedback
        6. Customer support
          1. Downloading the example code
          2. Errata
          3. Piracy
          4. Questions
      8. 1. Understanding Android
        1. Introducing Android
          1. Exploring the different versions of Android
          2. Google Play – the official app store for Android
        2. Understanding the whys and whens of Android
          1. The evolution of Android OS
        3. Official IDE from Google – the Android Studio
          1. Features of Android Studio
          2. Limitations of Android Studio
        4. Building blocks of an Android application
          1. Coding components
          2. Media components
            1. The assets folder
            2. The res folder
          3. XML components
            1. The layout folder
            2. The menu folder
            3. The values folder
            4. AndroidManifest.xml
          4. Referencing components
          5. Library components
        5. Android Activity lifecycle
          1. Fundamental states of an activity
          2. The callback methods of the Activity lifecycle
          3. The activity lifecycle flow
        6. Summary
      9. 2. Introduction to Android Intents
        1. Role of intents in an Android Application
          1. Role of intents in Android Activities
          2. Role of intents in data transfer between activities
          3. Role of intents in Wi-Fi and Bluetooth transfer
          4. Role of intents in Android Camera
          5. Role of intents in GPS Sensor
          6. Role of intents in sending SMS/MMS
          7. Role of intents in Mobile Calls
          8. Role of intents in e-mail and social network posts
          9. Role of intents in Android Services
          10. Role of intent in Broadcast Receiver
          11. Role of intent in time zones
          12. Role of intent in Status Bar
        2. Intent – a technical overview
          1. The Coding component
          2. The XML component
        3. Implementation of Android Intents for Activity Navigation
          1. Understanding the flow
            1. Part one –
            2. Part two –
            3. Part three – activity_main.xml
            4. Part four – activity_two_layout.xml
            5. Part five – AndroidManifest.xml
              1. Future considerations
          2. Other constructors of the android.content.Intent class
            1. Intent()
            2. Intent(intent o)
            3. Intent(Context c, Class<?> cls)
            4. Intent(String action)
            5. Intent(String action, URI uri)
          3. Getting results from Android Intents
            1. Understanding with an example
            2. Going deep into the example
            3. Explaining the code
              1. Part one –
              2. Part two –
              3. Part three – activity_main.xml
              4. Part four – activity_two_layout.xml
              5. Part five – AndroidManifest.xml
              6. Future considerations
        4. Structure of an intent
          1. Component
          2. Actions
          3. Data
          4. Extras
        5. Summary
      10. 3. Intent and Its Categorization
        1. Explicit intents
          1. Using explicit intents in an Android application
            1. Starting an activity through an explicit intent
              1. The class
              2. The class
              3. The activity_main.xml file
              4. The activity_main2.xml file
              5. The AndroidManifest.xml file
            2. Starting a service through an explicit intent
              1. The class
              2. The class
              3. The activity_main.xml file
              4. The AndroidManifest.xml file
        2. Implicit intents
          1. Using implicit intents in an Android application
            1. Sharing content using implicit intents
              1. The activity_main.xml file
              2. The class
              3. Registering your app for the share intent
              4. The activity_main.xml file
              5. The class
              6. The AndroidManifest.xml file
            2. Selecting an image through an implicit intent
              1. The activity_main.xml file
              2. The class
        3. Intents and Android late binding
        4. Summary
      11. 4. Intents for Mobile Components
        1. Common mobile components
          1. The Wi-Fi component
          2. The Bluetooth component
          3. The Cellular component
          4. Global Positioning System (GPS) and geo-location
          5. The Geomagnetic field component
          6. Sensor components
            1. Motion sensors
            2. Position sensors
            3. Environmental sensors
        2. Components and intents
          1. Communication components
            1. Using Bluetooth through intents
              1. Some Bluetooth API classes
                1. BluetoothDevice
                2. BluetoothAdapter
              2. Turning on the Bluetooth app
                1. The file
                2. The AndroidManifest.xml file
              3. Tracking the Bluetooth adapter state
                1. The file
                2. The file
              4. Being discoverable
              5. Monitoring the discoverability modes
              6. Communication via Bluetooth
            2. Using Wi-Fi through intents
              1. Checking the Internet connectivity status
                1. The file
                2. The AndroidManifest.xml file
              2. Opening the Wi-Fi Settings app
                1. The activity_main.xml file
                2. The file
          2. Media components
            1. Using intents to take pictures
              1. The activity_main.xml file
              2. The file
              3. The AndroidManifest.xml file
            2. Using intents to record video
            3. Speech recognition using intents
              1. The activity_main.xml file
              2. The file
            4. Role of intents in text-to-speech conversion
          3. Motion components
            1. Intents and proximity alerts
              1. What are proximity alerts?
            2. Role of intents in proximity alerts
        3. Summary
      12. 5. Data Transfer Using Intents
        1. Finding the need to transfer data
          1. Taking a simple example
        2. Data transfer between activities – an INTENTed way
        3. Data transfer in explicit intents
        4. Methods of data transfer between activities
          1. Data transfer using putExtras()
            1. Implementation of putExtras()
              1. Implement a readymade tutorial
              2. Understanding the code
                1. The class
                2. The class
                3. The main_first.xml file
                4. The main_second.xml file
                5. The AndroidManifest.xml file
                6. Future considerations
            2. Extras supported data types
            3. The concept of Android Bundles
          2. Data transfer using Parcelable
            1. Implementation of Parcelable
              1. Implement a readymade tutorial
              2. Understanding the Parcelable implementation
                1. The class
                2. The class
                3. The layout_activity1.xml file
                4. The layout_activity2.xml file
                5. The class
                6. The AndroidManifest.xml file
              3. Future Consideration
          3. Data transfer using Serializable
            1. What is Serializable?
            2. An example of Serializable
            3. Implementation of Serializable
              1. Passing Serializable – a tutorial
              2. Walking through the Serializable code
                1. The class
                2. The class
                3. The class
                4. The layout_activity1.xml file
                5. The layout_activity2.xml file
                6. The AndroidManifest.xml file
        5. Data and the implicit intents
          1. Viewing a map
          2. Opening a webpage
          3. Sending an e-mail
          4. Making a call
          5. Miscellaneous scenarios
        6. Summary
      13. 6. Accessing Android Features Using Intents
        1. Features of Android OS
        2. Android features versus components
        3. Common Android features
          1. Layouts and display
          2. Data storage and retrieval
          3. Connectivity and communication
          4. Accessibility and multitouch
          5. Extensive content and media support
          6. Hardware support
          7. Background services and multitasking
          8. Enhanced home screen
          9. Other Android features
        4. Android features and intents
        5. The <uses-feature> and <uses-permission> tags
          1. Hardware features
          2. Software features
        6. Sharing using the SEND action
        7. Telephony and making calls using intents
          1. Making phone calls using intents
        8. SMS/MMS using intents
          1. Sending SMS using intents
          2. Sending MMS using intents
          3. Confirming message delivery using intents
          4. Receiving SMS messages using intents
            1. The SmsManager class
            2. The SmsMessage object
            3. Protocol Data Unit (PDU)
        9. Notification using intents
          1. Notification forms
          2. The NotificationManager class
          3. The Notification class
          4. The Notification layout
        10. Summary
      14. 7. Intent Filters
        1. Intent object and its categorization
          1. Component name
            1. Intent resolution
          2. Action
          3. Data
            1. Use of data in ACTION_EDIT
            2. Use of data in ACTION_CALL
            3. Use of data in ACTION_VIEW
          4. Category
          5. Extras
        2. Intent filters
        3. Handling multiple intent filters
        4. Test components of an intent filter
          1. Action test
            1. Writing conventions for <action>
          2. Category test
            1. Setting up the launcher activity
          3. Data test
            1. Typical representation of the <data> tag
        5. Summary
      15. 8. Broadcasting Intents
        1. Broadcasting in the Android OS
          1. The broadcast intents
        2. Built-in broadcasts in Android systems
        3. Detecting the low-battery state of a device
          1. The file
          2. The class
          3. The AndroidManifest.xml file
        4. Detecting the screen on/off state of a phone
          1. The file
          2. The AndroidManifest.xml file
        5. Detecting the cell phone's reboot-completed state
          1. The file
          2. The file
          3. The AndroidManifest.xml file
        6. Sending and receiving custom broadcasts
          1. The activity_main.xml layout file
          2. The file
          3. The file
          4. The AndroidManifest.xml file
        7. Summary
      16. 9. Intent Service and Pending Intents
        1. Intent Service
          1. Comparison of four fundamentals
            1. Best case to use
            2. Triggers
        2. Usage and implementation of Intent Service
          1. Generating a fake notification from Intent Service
            1. A glance at the code
            2. Dive into the understanding
          2. Taking another example
        3. Pending Intents
          1. How to make Pending Intents work?
        4. Summary
      17. Index