15
Implicit Intents

In Android, you can start an activity in another application on the device using an intent. In an explicit intent, you specify the class of the activity to start, and the OS will start it. In an implicit intent, you describe the job that you need done, and the OS will start an activity in an appropriate application for you.

In CriminalIntent, you will use implicit intents to enable picking a suspect for a Crime from the user’s list of contacts and sending a text-based report of a crime. The user will choose a suspect from whatever contacts app is installed on the device and will be offered a choice of apps to send the crime report (Figure 15.1).

Figure 15.1  Opening contacts and text-sending apps

Opening contacts and text-sending apps

Using implicit intents to harness other applications is far easier than writing your own implementations for common tasks. Users also appreciate being able to use apps they already know and like in conjunction with your app.

Before you can create these implicit intents, there is some setup to do in CriminalIntent:

  • add CHOOSE SUSPECT and SEND CRIME REPORT buttons to CrimeFragment’s layouts

  • add a suspect property to the Crime class that will hold the name of a suspect

  • create a crime report using a set of format resource strings

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

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