This Study Resource Was: Chapter 1 Answers
This Study Resource Was: Chapter 1 Answers
This Study Resource Was: Chapter 1 Answers
1. What is an AVD?
An AVD is an Android Virtual Device. It represents an Android emulator,
which
Emulates a particular configuration of an actual Android device.
2. What is the difference between the android version Code and
android version Name attributes
In the AndroidManifest.xml file?
The android version Code attribute is used to programmatically check
whether an
Application can be upgraded. It should contain a running number (an
updated application
Is set to a higher number than the older version). The android version Name
attribute is
Used mainly for displaying to the user. It is a string, such as “1.0.1”.
3. What is the use of the strings.xml file?
m
er as
The strings.xml fi le is used to store all string constants in your application.
co
eH w
This enables you to easily localize your application by simply replacing the
strings and then Recompiling your application.
o.
CHAPTER 2 ANSWERS rs e
ou urc
1. What will happen if you have two or more activities with the same
intent filter action name?
The Android OS will display a dialog from which users can choose which
o
activity they
aC s
Want to use.
vi y re
category.
4. What is the difference between the Toast class and the
Th
This study source was downloaded by 100000827613812 from CourseHero.com on 06-07-2021 22:09:11 GMT -05:00
https://www.coursehero.com/file/59069423/short-questiondocx/
You can either use the <fragment> element in the XML fi le, or use the
Fragment Manager
And Fragment Transaction classes to dynamically add/remove fragments
from an activity.
6. Name one key difference between a fragment and an activity?
One of the main differences between activities and fragments is that when
an activity goes
Into the background, the activity is placed in the back stack. This allows an
activity to be
Resumed when the user presses the Back button. Conversely, fragments are
not automatically
Placed in the back stack when they go into the background.
CHAPTER 3 ANSWERS
m
er as
1. What is the difference between the dp unit and the PX
co
Unit? Which one should you use to specify the dimension of a view?
eH w
The dp unit is density independent and 1dp is equivalent to one pixel on a
160 dpi screen. The
o.
px unit corresponds to an actual pixel on screen. You should always use the
dp unit because it rs e
ou urc
Enables your activity to scale properly when run on devices of varying screen
size.
2. Why is the Absolute Layout not recommended for use?
o
With the advent of devices with different screen sizes, using the Absolute
aC s
Layout makes it
vi y re
difficult for your application to have a consistent look and feel across
devices.
3. What is the difference between the on Pause () method and the
ed d
On Save Instance State () event is like the on Pause () event, except that it is
not always
Th
Called, such as when the user presses the back button to kill the activity.
4. Name the three methods you can override to save an activity’s
state. In what instances should you
sh
This study source was downloaded by 100000827613812 from CourseHero.com on 06-07-2021 22:09:11 GMT -05:00
https://www.coursehero.com/file/59069423/short-questiondocx/
About to be destroyed. However, for screen orientation changes, it is easier
to use the
On Save Instance State () method to save the state of the activity (such as
the data entered
By the user) using a Bundle object. The on Retain Non Configuration Instance
() method is
Useful for momentarily saving data (such as images or fi les downloaded
from a web service)
Which might be too large to fi t into a Bundle object.
5. How do you add action items to the Action Bar?
Adding action items to the Action Bar is similar to creating menu items for
an options
Menu — simply handle the on Create Options Menu () and on Options Item
Selected () events.
m
CHAPTER 4 ANSWERS
er as
1. How do you programmatically determine whether a Radio Button
co
is checked?
eH w
You should check the is Checked () method of each Radio Button to
o.
determine whether it
has been checked. rs e
ou urc
2. How do you access the string resource stored in the strings.xml
file?
You can use the get Resources () method.
o
Their uses?
Th
The three specialized fragments are List Fragment, Dialog Fragment, and
Preference Fragment. The List Fragment is useful for displaying a list of
items, such as
sh
An RSS listing of news items. The Dialog Fragment allows you to display a
dialog window
Modally and is useful to get a response from the user before allowing him to
continue
This study source was downloaded by 100000827613812 from CourseHero.com on 06-07-2021 22:09:11 GMT -05:00
https://www.coursehero.com/file/59069423/short-questiondocx/
With your application. The Preference Fragment displays a window containing
your
Application’s preferences and allows the user to edit them directly in your
application.
CHAPTER 5 ANSWERS
1. What is the purpose of the Image Switcher?
The Image Switcher enables images to be displayed with animation. You can
animate the
Image when it is being displayed, as well as when it is being replaced by
another image.
2. Name the two methods you need to override when implementing
an options menu in your activity?
The two methods are on Create Options Menu () and on Options Item
Selected ().
3. Name the two methods you need to override when implementing
m
er as
a context menu in your activity?
The two methods are on Create Context Menu () and on Context Item
co
eH w
Selected ().
4. How do you prevent the Web View from invoking the device’s web
o.
browser when a redirection
Occurs in the Web View? rs e
ou urc
To prevent launching the device’s web browser, you need to implement the
Web View Client
o
CHAPTER 6 ANSWERS
1. How do you display the preferences of your application using an
activity?
You can do so using the Preference Activity class.
ed d
2. Name the method that enables you to obtain the path of the
ar stu
This study source was downloaded by 100000827613812 from CourseHero.com on 06-07-2021 22:09:11 GMT -05:00
https://www.coursehero.com/file/59069423/short-questiondocx/
ContactsContract.Contacts.DISPLAY_NAME + “ LIKE ?”,
new String[] {“%jack”},
ContactsContract.Contacts.DISPLAY_NAME + “ ASC”);
} else {
//---Honeycomb and later---
CursorLoader cursorLoader = new CursorLoader(
this,
allContacts,
projection,
ContactsContract.Contacts.DISPLAY_NAME + “ LIKE ?”,
new String[] {“%jack”},
ContactsContract.Contacts.DISPLAY_NAME + “ ASC”);
c = cursorLoader.loadInBackground();
}
2. Name the methods that you need to override in your own
implementation of a content provider?
m
er as
The methods are getType(), onCreate(), query(), insert(), delete(), and
update().
co
eH w
3. How do you register a content provider in your
AndroidManifest.xml file?
o.
The code is as follows:
rs e
<provider android:name=”BooksProvider”
ou urc
android:authorities=”net.learn2develop.provider.Books” />
CHAPTER 8 ANSWERS
o
1. Name the two ways in which you can send SMS messages in your
aC s
Android application?
vi y re
You can either programmatically send an SMS message from within your
Android application
or invoke the built-in Messaging application to send it on your
ed d
application’s behalf.
2. Name the permissions you need to declare in your
ar stu
1. If you have embedded the Google Maps API into your Android
application but it does not show
the map when the application is loaded, what could be the likely
reasons?
The likely reasons are as follows:
➤ No Internet connection
This study source was downloaded by 100000827613812 from CourseHero.com on 06-07-2021 22:09:11 GMT -05:00
https://www.coursehero.com/file/59069423/short-questiondocx/
➤ Incorrect placement of the <uses-library> element in the
AndroidManifest.xml fi le
➤ Missing INTERNET permission in the AndroidManifest.xml fi le
2. What is the difference between geocoding and reverse
geocoding?
Geocoding is the act of converting an address into its coordinates
(latitude and longitude).
Reverse geocoding converts a pair of location coordinates into an
address.
3. Name the two location providers that you can use to obtain your
location data?
The two providers are as follows:
➤ LocationManager.GPS_PROVIDER
➤ LocationManager.NETWORK_PROVIDER
m
er as
The method is addProximityAlert().
CHAPTER 10 ANSWERS
co
eH w
1. Name the permissions you need to declare in your
AndroidManifest.xml file for an HTTP
o.
connection?
rs e
ou urc
The permission is INTERNET.
2. Name the classes used for dealing with JSON messages?
The classes are JSONArray and JSONObject.
3. Name the class for performing background asynchronous tasks?
o
CHAPTER 11 ANSWERS
vi y re
The IntentService class is similar to the Service class, except that it runs
Th
the tasks in a
separate thread and automatically stops the service when the task has
finished execution.
3. Name the three methods you need to implement in an AsyncTask
sh
class?
The three methods are doInBackground(), onProgressUpdate(), and
onPostExecute().
4. How can a service notify an activity of an event happening?
The service can broadcast an intent, and the activity can register an
intent using an
This study source was downloaded by 100000827613812 from CourseHero.com on 06-07-2021 22:09:11 GMT -05:00
https://www.coursehero.com/file/59069423/short-questiondocx/
IntentFilter class.
5. For threading, what is the recommended method to ensure that
your code runs without tying up
the UI of your application?
The recommended method is to create a class that subclasses the
AsyncTask class. This will
ensure that the UI is updated in a thread-safe manner.
CHAPTER 12 ANSWERS
1. How do you specify the minimum version of Android required by
your application?
You specify the minimum Android version required using the
minSdkVersion attribute in
the AndroidManifest.xml file.
2. How do you generate a self-signed certificate for signing your
Android application?
To generate a certificate, you can either use the keytool.exe utility from
m
er as
the Java SDK or
co
use Eclipse’s Export feature.
eH w
3. How do you configure your Android device to accept applications
from non-Market sources?
o.
rs e
Go to the Settings application and select the Security item. Check the
ou urc
“Unknown sources” item.
o
aC s
vi y re
ed d
ar stu
is
Th
sh
This study source was downloaded by 100000827613812 from CourseHero.com on 06-07-2021 22:09:11 GMT -05:00
https://www.coursehero.com/file/59069423/short-questiondocx/
Powered by TCPDF (www.tcpdf.org)