Chapter 8. Mastering Intents – A Walkthrough

In this chapter, you will learn the details behind Intent implementation and use with the following recipes:

  • Opening external applications
  • Monitoring time
  • Application monitoring
  • Solving equations
  • Sending an SMS

Introduction

In the previous chapter, that is, Chapter 7, Using Android Services, we used Intents to communicate with background services and didn't pay too much attention to them. Android Intent is a component of the Android OS responsible for triggering an operation. While Ruby developers tend to master this concept, it's a little bit trickier for the rest of us.

In the previous chapter, we used Intent to communicate with background services as follows:

StartService (new Intent (this, typeof(MyService)));

And even in more complicated ways like this:

[Service]
[IntentFilter(new String[]{"ca.services.MyService"})]
public class MyService : Service
Intent MyIntent = new Intent ("ca.services.MyService");
StartService (MyIntent);

However, we didn't put much thought into this and barely used them as a convenient way to communicate with our background services. Android Intents are, from my point of view, a useful UFO in the Android ecosystem. Indeed, the Intent object is a concept that allows us to abstractly describe operations that we intend to do in an asynchronous way. Concretely, Intents are often used to launch an external application such as maps, phone, or messages. Moreover, we can use an Intent for more powerful purposes such as browsing through the contact list or interacting with e-mails.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.145.60.29