Android How to Program Chapter 14 Solution Manual
Download file with the answers
Android How to Program Chapter 14 Solution Manual
1 file(s) 275.50 KB
If you are not a member register here to download this file
14 Weather Viewer App
Obj e c t i v e s
In this chapter you’ll:
■ Use WeatherBug® web
services to get the current
conditions and five-day
forecast for a specified city
and process that data using
an Android 3.x
JsonReader.
■ Use various types of
Fragments to create
reusable components and
make better use of the screen
real estate in a tablet app.
■ Implement tabbed navigation
using the Android 3.x
ActionBar.
■ Create a companion app
widget that can be installed
on the user’s home screen.
■ Broadcast changes of the
app’s preferred city to the
companion app widget.
2 Chapter 14 Weather Viewer App
Self-Review Exercises
14.1 Fill in the blanks in each of the following statements:
a) A ListFragment is a Fragment containing a .
b) A FragmentTransaction (package android.app) obtained from the allows
the Activity to add, remove and transition between Fragments.
c) We extend class AppWidgetProvider (package android.appwidget), a subclass of
(package android.content), to create an app widget and allow it to receive
notifications from the system when the app widget is enabled, disabled, deleted or updated.
d) You can force an item to appear in the ActionBar by using the always value of attribute
but you risk overlapping menu items by doing so.
14.2 State whether each of the following is true or false. If false, explain why.
a) (True/False) Fragments were introduced in Android 3.x and cannot be used with earlier
versions of Android.
b) (True/False) The action bar can display the app’s options menu, navigation elements
(such as tabbed navigation) and other interactive GUI components.
c) (True/False) Unlike activities, services need not be registered in the manifest.
d) (True/False) JSON (JavaScript Object Notation)—a simple way to represent JavaScript
objects as numbers—is an alternative to XML for passing data between the client and
the server.
as strings—is an alternative to XML for passing data between the client and the
server.
e) (True/False) Arrays are represented in JSON with curly braces in the following format:
f) (True/False) Class JsonReader provides methods for reading booleans, doubles, ints,
longs and Strings.
g) (True/False) A PendingIntent cannot be passed across processes.
h) (True/False) Use Fragments to create reusable components and make better use of the
screen real estate in a tablet app.
Exercises
14.3 Fill in the blanks in each of the following statements:
{ value1, value2, value3 }
Exercises 3
a) An Activity’s (package android.content.res) can be used to determine
the current orientation.
b) Use a(n) (package android.util) to read JSON objects.
c) The attribute android:showAsAction defines how a menu item should appear in the ActionBar.
The value specifies that this item should be visible in the Action-
Bar if there’s room to lay it out completely.
d) We get the name from the next name–value pair in a JSON object by calling JsonReader’s
method.
e) You use a FragmentManager to manage the Fragments and a to add, remove
and transition between Fragments.
14.4 State whether each of the following is true or false. If false, explain why.
a) (True/False) Fragments are a key feature of Android 3.x.
b) (True/False) The base class of all fragments is BaseFragment (package android.app).
c) (True/False) Like an Activity, each Fragment has a life cycle.
d) (True/False) Fragments can be executed independently of a parent Activity.
e) (True/False) It’s common practice to allow a user to launch an app by touching the app’s
companion widget on the device’s home screen.
f) (True/False) Each object in JSON is represented as a list of property names and values
contained in curly braces, in the following format:
g) (True/False) Each value in a JSON array can be a string, a number, a JSON representation
of an object, true, false or null.
h) (True/False) When updating an app widget from an AppWidgetProvider, you update
the app widget’s Views directly.
Leave a reply