Andriod Ch 6-13

¡Supera tus tareas y exámenes ahora con Quizwiz!

Within a <style> element, which of the following elements would set the text size of the style to 15sp?

<item name="android:textSize">15sp</item>

What element do you add to a project's AndroidManifest.xml file to register a broadcast receiver?

A receiver element

Which permission is required for a broadcast receiver for the CONNECTIVITY_CHANGE action?

ACCESS_NETWORK_STATE

This broadcast is typically used to resume activities that consume power.

ACTION_BATTERY_OKAY

This broadcast is typically used to start services that should always run.

ACTION_BOOT_COMPLETED

<?xml version="1.0" encoding="utf-8"?> <resources> <item name="activity_main" type="layout"> @layout/activity_main_threepane </item> </resources> What type of resource does this XML code define?

An alias

Which version of Android introduced fragments?

Android 3.0 (API 11)

The ________________ file uses its application element to specify the theme for the application.

AndroidManifest.xml

You can open the ________________ file and edit it to apply a theme to the entire application or to a specific activity.

AndroidManifest.xml

This broadcast is typically used to check whether a change in network connectivity has occurred.

CONNECTIVITY_ACTION

Which XML element do you use to code a preference that uses a check box?

CheckBoxPreference

The ________________ event of a check box or radio button occurs when a check box or radio button is checked or unchecked

CheckChanged

To check if a network connection is available to the device, you can use a/an ________________ object.

ConnectivityManager

To work with a database that's on your computer (not on a device or emulator), you can use a tool like the

DB Browser for SQLite

The KeyEvent class contains constants for almost every possible hardware key on a device including the keys on a

DPad

How do you code the opening tag for a style named Label that inherits a style named TextView.

Either <style name="Label" parent="@style/TextView"> OR <style name="TextView.Label">

Given a FILENAME constant that specifies a valid filename for a file, which statement can you use to get a stream to write data to that file?

FileOutputStream out = openFileOutput(FILENAME, Context.MODE_PRIVATE);

When coding the class for a fragment, what class do you typically extend?

Fragment

Given the following statement that creates a URL object, which statement can you use to open a stream to read data from that URL? URL url = new URL("http://www.murach.com/new_books.rss");

InputStream in = url.openStream();

. In an activity, which of the following statements can you use to get the intent that started the activity and retrieve a string named title that has been stored in that intent?

Intent intent = getIntent(); String title = intent.getStringExtra("title");

. Given the following Uri object, which of the following statements creates an Intent object that you can use to place the specified phone number in the dialer without starting the call? Uri uri = Uri.parse("tel:123-456-7890");

Intent intent = new Intent(Intent.ACTION_DIAL, uri);

Given the following Uri object, which of the following statements creates an Intent object that you can use to view the specified URL in a web browser? Uri uri = Uri.parse("http://www.murach.com/");

Intent intent = new Intent(Intent.ACTION_VIEW, uri);

You can use Java and Android APIs to download a file by reading input from the ________________ and writing output to the ________________ .

Internet, file system

What does the following code do? ArrayList> data = new ArrayList>(); for (Books book : books) { HashMap map = new HashMap(); map.put("title", book.getTitle()); map.put("author", book.getAuthor()); map.put("price", book.getPrice()); data.add(map); }

It creates a variable named data that stores the data for an adapter

<fragment android:name="com.murach.newsreader.ItemsFragment" android:id="@+id/items_fragment" android:layout_weight="1" android:layout_width="0dp" android:layout_height="match_parent" /> Which of the following are true about this code?

It displays the fragment defined by the ItemsFragment class, It sizes the fragment so it's as tall as the parent container and This fragment has an ID of items_fragment

Assume the prefs object is a SharedPreferences object. What does the following statement do? deleteOldMessages = prefs.getBoolean("delete_old_messages", true);

It returns the default value for the preference with a key of "delete_old_messages".

What does the following statement do? startActivity(new Intent(getApplicationContext(), SettingsActivity.class));

It starts the activity that's defined by the class named SettingsActivity.

Which is true about a fragment?

It's a class that you can use to define part of the user interface, It can be reused in multiple activities, and It can also be referred to as a pane

You can use ________________ code to register and unregister a broadcast receiver.

Java

When a user presses a hardware button on a device, a/an ________________ event occurs.

Key

To test a service, it's common to use the ___________ class to print messages.

Log

To display or remove a notification, you can use a/an ________________ object.

NotificationManager

The AsyncTask class provides for these generic types:

Params, Progress, Result

Android provides ________________ that allow you to build an interface that's consistent with the user experience in other Android apps.

Preference APIs

If the user interface for a fragment uses Preference objects instead of View objects, the fragment needs to extend the ________________ class instead of the Fragment class.

PreferenceFragment

A/an ________________ feed can be used to publish frequently updated works, such as blog entries and news headlines.

Rich Site Summary

To parse XML files, you can use ________________ .

SAX (simple API for xcel)

The _________________ class provides the onCreate and onUpgrade methods that are used to create and upgrade the database.

SQLiteOpenHelper

To display data in a ListView widget, you can use the ________________ class.

Simple Adapter

Which of the following Java data types does SQLite support?

String

A/an ________________ is a collection of properties that specify formatting for a widget.

Style

A/an ________________ is a collection of styles that can be applied througout an application.

Style sheet

@Override public void onCheckedChanged(CompoundButton widget, boolean isChecked) { deleteOldMessages = isChecked; } Assuming this method is wired to a CheckBox widget, what happens when the user checks that box?

The deleteOldMessages variable is set to true

What attributes do you use to set the names and values of the items on an XML element for a list box preference?

The entries attribute and the entryValues attribute

A/an ________________ is a collection of styles that apply to an entire activity or app.

Theme

Which of the following is a disadvantage of using a fragment to use the Preferences API to display preferences?

This technique only works with Android 3.0 (API 11) and later

To create a thread that executes tasks after a specified delay or at a specified interval, use the ________________ class

Timer and TimerTask

When a user touches a widget on a touchscreen device, a/an ________________ event occurs on the widget.

Touch

By default, an Android app uses a single thread, called the ________________, to display the user interface. Any task that can slow or stop the responsiveness of this should be run in a separate thread.

UI Thread

Given an Application object named WeatherApp, which of the following gets the Application object?

WeatherApp app = (WeatherApp) getApplication();

If you want to execute a task in the background once every hour, even if the app is no longer running, you can use ______________ to start a timer that runs the task.

a service

Every broadcast has a/an ________________ string that uniquely identifies the action.

action

With Android 4.0 (API 14) and later, an activity can include a/an ________________ that displays the activity's title and, optionally, buttons that perform actions.

action bar

By default, if you specify an icon for an item, Android uses that icon in the ________________, but it uses text for that item in the ________________

action bar, options menu

If a device doesn't have a physical Menu button, a/an ________________ is displayed on the right side of the action bar to display the options menu.

action overflow icon

Which of the following menu item attributes displays the icon for the menu item in the action bar only when there's enough room in the action bar to fit the icon?

android:showAsAction="ifRoom"

You can create an instance variable that creates an object from a class that implements the listener interface. Since this class doesn't have a name, it's known as a/an ________________ class.

anonymous

You can create an instance of a listener interface without assigning it to an instance variable. This is known as a/an ________________ class.

anonymous inner

A task that runs in a separate thread in the background and does not need to be synchronized with other threads is called a/an ________________ task.

asynchronous

A stack of all recently used activities, sorted in the order in which they were used is called a/an ________________.

back stack

The Android operating system ________________ certain ________________ that occur as a device is being used.

broadcasts, actions

Which of the following declares a class for an asynchronous thread?

class GetItems extends AsyncTask<String, Void, String> {}

The built-in style called TextAppearance.Small.Inverse displays a small font size and inverse ________________.

color scheme

To define names for colors, you typically add a/an ________________ file to the res/values directory.

colors.xml

Given a SQLiteDatabase object named db and a constant named CREATE_CITIES_TABLE that contains a valid CREATE TABLE statement, what does the following code do? db.execSQL(CREATE_CITIES_TABLE);

creates the specified table

A type of thread that ends when the app ends is called a/an

daemon thread

You can enable or disable a preference by using its ________________ attribute to link the preference to a corresponding CheckBoxPreference element.

dependency

Within a class for an asynchronous thread, which of the following methods is executed on the asynchronous thread?

doInBackground(Params...)

An unbound service

does not interact with other components such as activities, runs until it's stopped by another component, runs until it's stopped by itself (all of the above)

To view a notification, the user can pull down on the notification area to open the notification ________________.

drawer

When a/an ________________ occurs on a widget, the appropriate method of the ________________ object is executed.

event, listener

A/an ________________ intent specifies a component such as an activity, and can be used to pass data from one activity to another.

explicit

To add more than one fragment to a layout, add two or more ________________ to a layout file.

fragment elements

The AsyncTask class uses _____________ to allow a class to operate on various types of objects.

generics

You can use a FragmentManager object to

get a reference to a Fragment object and replace one fragment with another fragment.

From a fragment or activity, you can call the ________________ method to get a FragmentManager object that you can use to find and work with the fragments in your app.

getFragmentManager

To determine which widget an event occured on, you use the ________________ method of the View class.

getID

If you want to get String data from the intent for a broadcast action, what method of the Intent class can you use?

getStringExtra

Given a SQLiteDatabase object named db and a variable named taskID that contains a valid ID for a task, what does the following code do? String where = "_id = ?"; String[] whereArgs = { Integer.toString(taskID) }; this.openReadableDB(); Cursor cursor = db.query("task", null, where, whereArgs, null, null, null);

gets a Cursor object that contains a single row from the task table that corresponds with the specified task ID

To specify a color, you can use ________________ values to specify an RGB value.

hex

An interface that defines a listener for a/an ________________ event is typically nested within the class that defines the widget. These listeners can only be wired to an appropriate widget.

high-level

The back stack for a particular task is called the task ________________.

history

A/an ________________ intent specifies the action you want to perform, and can be used to view a URL in a web browser or to call a phone number.

implicit

Within the onCreateOptionsMenu method, you typically use a MenuInflater object to ________________ the XML for the menu items into Java objects and store them in the Menu parameter.

inflate

Which method of the SQLiteDatabase class can you use to add a row to a table?

insert

A/an ________________ provides a description of an operation to be performed. This type of object can be used with the startActivity method to start activities.

intent

Within an XML file that defines styles, a property of a style is specified by a/an ________________.

item element

A menu can contain one or more ________________ .

items

To detect screen orientation, you can create a values directory that uses the ________________ or ________________ qualifiers.

land, port

An interface that defines the listener for a/an ________________ event is typically nested within the adroid.view.View class. These listerners can be wired to any type of widget.

low-level

Assume you have the following constant value, a NotificationManager object named manager, and a Notification object named notification. Which of the following statements removes the notification? final int NOTIFICATION_ID = 999;

manager.cancel(NOTIFICATION_ID);

Assume you have the following constant value, a NotificationManager object named manager, and a Notification object named notification. Which of the following statements displays the notification?

manager.notify(NOTIFICATION_ID, notification);

The action bar can include ________________

menu items

@Override public void onItemSelected(AdapterView<?> parent, View v, int position, long id) { month = 0; } Assume that this method is wired to a Spinner widget that displays the 12 months in order (January, February, March, etc.). How can you change the statement in this method so that the month variable stores a value of 1 for January, 2 for February, 3 for March, etc.?

month = position + 1;

On a large screen, an activity can display multiple fragments. This is know as a/an ________________ layout.

multi-pane

It's generally considered a good practice to define constants for the ________________ of the database

name and version number (both a and b)

. It's common to code the class for an asynchronous thread as a/an ________________ class of the activity

nested inner

You can group preferences by ________________ one or more Preference elements within a PreferenceCategory element

nesting

A/an ________________ provides a way for a service to display a message even when another app is running.

notification

When it's first displayed, a notification appears as an icon in the ________________ at the top of the screen.

notification area

Which methods are called for a bound service?

onCreate(), onBind(), onUnbind()

Which methods are called for an unbound service?

onCreate(), onStartCommand(), onDestroy()

Android calls the ________________ method when it's time to display the layout for the fragment. This occurs after the onCreate method, but before the onStart method.

onCreateView

When it's time to remove the fragment's layout from the activity, Android calls the ________________ method. This occurs after the onStop method but before the onDestroy method.

onDestroyView

Which method is executed when the user selects one of the items in the ListView widget?

onItemClick

For a spinner, the ________________ method is executed when the spinner is first displayed and whenever a new item is selected.

onItemSelected

For a spinner, the ________________ method is only executed when the selection disappears.

onNothingSelected

Which method do you typically override to handle the event that occurs when a user selects an item from the options menu?

onOptionsItemSelected

Within a class for an asynchronous thread, which of the following methods is executed on the UI thread after the asynchronous thread has finished executing?

onPostExecute(Result)

For a seek bar, the ________________ method is executed as the user changes the value of the seek bar.

onProgressChanged

When you code a class that defines a broadcast receiver, you override a method that's executed when the broadcast is received. What's the name of this method?

onReceive

An activity can include a/an ________________ that includes one or more ________________

options menu, menu items

A/an ________________ intent is an intent that can be passed to other apps so that they can execute the intent at a later time.

pending

In SQLite, a/an ________________ column requires that each row must have a value, and that value must be unique.

primary key

In a values directory, an alias

provides a way to avoid duplicating code in mulitple layout files and points to a layout file that's stored in a layout directory

Which of the following creates an Application object named WeatherApp?

public class WeatherApp extends Application {}

Which statement follows the best practices for defining a constant for an action that can be broadcast?

public final static String ACTION_NEW = "com.murach.weather.ACTION_NEW";

If you want to pass data to the receiver, what method of the Intent class can you use to store data in the Intent object?

putExtra

A broadcast _______________ is an application component that listens for a broadcast and executes code when it receives that broadcast.

receiver

Before you can use an Application object or a service, you must ________________ it.

register

What directory is used to store the XML for a menu?

res\menu

<?xml version="1.0" encoding="utf-8"?> <resources> <item name="activity_main" type="layout"> @layout/activity_main_threepane </item> </resources> What file should you store this code in if you want it to display the activity_main_threepane layout instead of the activity_main layout only when device is in landscape orientation and the smallest side of the device is at least 720dp?

res\values-sw720dp-land\layout.xml

What directory is used to store the XML for a preferences screen?

res\xml

A service

runs in the background

SQLite is an embedded database. This means that it

runs in the same process as the client app

A bound service

runs only as long as another component is bound to it

Given a TextView widget named secondsTextView and a Runnable object named updateSeconds, which statement updates the widget on the UI thread?

secondsTextView.post(updateSeconds);

Given an Intent named intent for a broadcast action, which of the following statements sends the broadcast?

sendBroadcast(intent);

Which of the following statements can you code within the class for a fragment to indicate that the fragment contains menu items to contribute to the options menu for the activity?

setHasOptionsMenu(true);

The lifecycle methods of a fragment are ________________ to the lifecycle methods of an activity.

similar

On a small screen, an activity typically only displays a single fragment. This is know as a/an

single-pane layout

The ________________ qualifier allows you to select screens whose smallest width is at least as wide as specified width.

smallest-width

Given the following Intent object for a service, which of the following statements starts the service? Intent serviceIntent = new Intent(this, WeatherService.class);

startService(serviceIntent);

Which of the following attributes sets the style for the widget to the Spinner style?

style="@style/Spinner"

If necessary, you can use multiple ________________ files to set appropriate themes for the different API levels.

styles.xml

@Override public void onCheckedChanged(CompoundButton widget, boolean isChecked) { deleteOldMessages = isChecked; } If you decided to wire this event handler to multiple check boxes, which switch statement could you add to this method to compare the ID of the check box that was changed with the IDs of the check boxes on the layout?

switch (widget.getId()) { ... }

A/an ________________ service is a service that's provided by the Android operating system.

system

It's generally considered a good practice to define constants for the

table names, column names, and column numbers (all of the above)

A/an ________________ is a cohesive unit that can contain multiple activities.

task

For an asynchronous task, within the inner class, you can access the context for the activity by coding

the name of the outer class, a period, and the this keyword

Holo, Material, and Holo.Light.DarkActionBar are all names of ________________ .

themes

A/an ________________ is a single sequential flow of control within a program that often completes a specific task.

thread

Given a Timer object named timer and a TimerTask object named task, which of the following statements runs the task immediately and again every minute?

timer.schedule(task, 0, 60000);

To apply a color, you can

use a hex value, use a name for a user-defined color, or use a name for a built-in Android color.

To handle an event, you can

use the current class as the listener, use an anonymous inner class as the listener, and use a named class as the listener

If a broadcast receiver uses permissions, you can request those permissions by adding an element to the AndroidManifest.xml file. What's the name of that element?

uses-permission

If you make changes to the structure of the database, you can increment the ________________ for the database.

version number

SQLite is ________________-typed, meaning a column in a SQLite database does not reject a value of an incorrect data type.

weakly

To test the database class, you can

write code that creates an instance of the database class and uses its public methods, display data on the user interface, display the data in the LogCat view (all of the above)


Conjuntos de estudio relacionados

Chapter 23: Cells and Tissues of the Plant Body

View Set

fahmy 100 ( bible ) arabic & french 14

View Set

Ch 8: Florida Statutes the surplus lines law

View Set

Chapter 32: All Forms of Partnerships

View Set

MUSCLES THAT ACT ON EACH DIGIT: Digit 5 (Pinky)

View Set