Android Programming The Big Nerd Ranch Guide by Bill Phillips, Chris Stewart, Kristin Marsicano (z-lib.org)
28. Background Services All the code you have written so far has been hooked up to an activity, which means that it is associate ...
Chapter 28 Background Services A service’s intents are called commands. Each command is an instruction to the service to do som ...
Creating an IntentService Because services, like activities, respond to intents, they must also be declared in your AndroidManif ...
Chapter 28 Background Services What Services Are For OK, we admit it: Looking at those Logcat statements was boring. But this c ...
Safe background networking Listing 28.4 Checking for background network availability (PollService.java) public class PollServic ...
Chapter 28 Background Services Looking for New Results Your service will be polling for new results, so it will need to know wh ...
Looking for New Results Return to PollService.java and put this plan into action. Listing 28.7 shows a long swath of code, but i ...
Chapter 28 Background Services Delayed Execution with AlarmManager To actually use your service in the background, you will nee ...
Being a good citizen: using alarms the right way After that, you need to either set the alarm or cancel it. To set the alarm, yo ...
Chapter 28 Background Services Repeating alarms: not so exact The setRepeating(...) method sets a repeating alarm, but that rep ...
PendingIntent PendingIntent Let’s talk a little bit more about PendingIntent. A PendingIntent is a token object. When you get on ...
Chapter 28 Background Services Controlling Your Alarm Now that you can turn your alarm on and off (as well as tell whether it i ...
Controlling Your Alarm Now delete your old debug code for starting the alarm and add an implementation for the menu item. Listin ...
Chapter 28 Background Services In onCreateOptionsMenu(...), check whether the alarm is on and change the text of menu_item_togg ...
Notifications Notifications Your service is now running and doing its thing in the background. But the user never knows a thing ...
Chapter 28 Background Services Make PollService notify the user that a new result is ready by creating a Notification and calli ...
Challenge: Notifications on Android Wear notification. It should be unique across your application. If you post a second notific ...
Chapter 28 Background Services Let’s see what lifecycle callbacks a service has. A service’s lifecycle For a service started wi ...
Bound services Once a sticky service is started, it is “on” until a component calls Context.stopService(Intent). If the service ...
Chapter 28 Background Services private class MyBinder extends IBinder { public MyService getService() { return MyService.this; ...
«
24
25
26
27
28
29
30
31
32
33
»
Free download pdf