540 CHAPTER 14: Android Content Providers: Providing Data to Applications
The next line of code will use the Android Toast class to write the ruler name data to the user’s display
screen, as each record is processed. The Toast class is used to construct View object that contains
a system broadcast message for your users. When this View object is displayed to your users, it will
appear as an oval floating over the bottom of your application. If you want to look ahead and see what
a Toast broadcast message looks like, there is one in Figure 1 4-3 3 on the bottom-right side.
Figure 14-33. Use Nexus One AVD to test the List All Galaxy Rulers Button (left) and Toast of Ruler names (right)
A Toast broadcast message is unable to receive focus because it is simply an OS broadcast
notification. This is because when the Android OS broadcasts a Toast message, which it often does
for its own purposes, your users could be in the middle of typing something that requires constant
focus (the OS kind, not the user’s focus!).
The no focus for Toast broadcast messages concept here is to be as unobtrusive as possible while
still showing the user the required information. Another example of the use of Toast broadcast
message implementation is a brief message saying that your settings have been saved if the user
uses your Setting menu option for your application and changes one of the global application
settings.
I am going to show you the easiest way to use this class, and the standard way that it is used, by
calling the static .makeText( ) method off of the Toast object itself. This will construct a Toast object
containing everything you need to broadcast your messages to your users. The format for the
Toast.makeText( ) method call and its three parameters, as well as a chained .show( ) method call