Bummer! This is just a preview. You need to be signed in with a Basic account to view the entire video.
Communication is Hard2:56 with Ben Jakuben
Communication is hard. Lucky for us, though, communication in Android apps is pretty easy thanks to a wonderful invention called Intents. In this video we'll talk about the common ways to share data and communicate in apps and between apps.
This course is built on the Music Machine app that is built in the Threads and Services course. We'll provide you with updated project files in the next video, but this course will serve you best if you take that prerequisite first.
[MUSIC] 0:00 Hello I'm Ben and I'd like to help you be a better communicator. 0:04 Well what I mean is I'd like to get you better at sharing. 0:08 Wait that's not right. 0:12 Let's try this again. 0:13 I'd like to show you how to share data in Android in ways that 0:14 seamlessly integrate your apps with other apps in the Android system. 0:18 Listen, communication is hard. 0:23 Lucky for us though, communication in Android is pretty easy 0:26 thanks to a wonderful invention called Intents. 0:29 You're hopefully pretty familiar with the concept of Intents at this point. 0:31 If not, I'd urge you to check the teacher's notes for prerequisites and 0:35 related material here at Treehouse that you should check out. 0:39 We'll review all the basics, but 0:42 we'll also dive deeper and look at special cases. 0:43 So don't worry if at first this feels like stuff you already know. 0:46 All right, so let's review what we do know about Intents. 0:48 The name itself is a big clue, 0:53 the Android Intents are objects that we can use to express our intentions. 0:55 For example, when we intend to start a new activity or service, we create an Intent 0:59 or maybe we intend to share some data in another app like Facebook or WhatsApp. 1:05 We use Intents in that case too but we configure them a little bit differently. 1:10 The thing to remember is that Intents are all about passing information around. 1:15 We can pass all sorts of data, in all sorts of ways. 1:20 Text, dates, images, complex data models, Intents can handle it all. 1:23 And we can use Intents to communicate to all sorts of things in the Android system. 1:28 Inside of our own app we can share data from one activity to another, 1:32 from an activity to a service, or from a service back to an activity. 1:36 But it doesn't end there, we can also use Intents to share data with another app or 1:40 to broadcast it system-wide. 1:44 We can also listen for system-wide broadcasts. 1:47 Let's say we're working on an app that can handle phone calls. 1:49 The system takes care of the low-level details of sending and 1:52 receiving phone calls. 1:55 But it broadcasts the data about a call in a way that we can listen for and 1:56 do something about. 2:00 We listen for these system wide broadcasts using something called 2:01 a broadcast receiver. 2:05 We have a great example app to work from here. 2:07 You may have worked on the MusicMachine app in a previous course. 2:09 But if not, don't worry, we're going to download a new version in the next video 2:13 that contains a few minor new things. 2:16 This app plays a simple song using a background service but 2:19 we will extend it to demonstrate these different ways of sharing data. 2:22 We're going to work our way through this list of examples. 2:24 We already know how to do some of these types of sharing. 2:29 But we'll review those and then pave our way forward with new examples. 2:31 Notice that device to device communication was left off of that list. 2:36 That requires sending data over the network and either pulling it from or 2:40 pushing it to another device. 2:44 That's beyond the scope of this course but check the teachers notes for 2:47 more information. 2:49 All right it's time to get started. 2:51 I intend to have lots of fun. 2:53 It's going to be great. 2:55
You need to sign up for Treehouse in order to download course files.Sign up