Quiz 4-8 Flashcards

1
Q

Which function do you call to find out where your application has been installed on the device?

A

getFilesDir()

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

Which function do you call if you want to display a message in the logcat window at the Debug level of importance?

A

Log.d(“message”);

must be capitalized, must have something in the parenthesis

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

If a SharedPreferences file has an int object stored under the name “Age”, what function would you call to retrieve the saved value? Just write the function name, the variable name, and assume a default value of 1, and also include the semicolon at the end.

A

getInt(“Age”, 1);

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

What <uses-feature> do you need to add to the AndroidManifest in order to use the camera? Copy and paste the entire line here:</uses-feature>

A

uses-feature android:name=”android.hardware.camera” android:required=”true” /

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

Sort these functions in order that they are called when starting an Activity.

____ onResume
____ onPause
____ onStop
____ onStart
____ onCreate
____ onDestroy

A

__3__ onResume
__4__ onPause
__5__ onStop
__2__ onStart
__1__ onCreate
__6__ onDestroy

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

The RecyclerView is not part of the normal Android widgets. What library do you have to add to the build.gradle file to add support for the Recycler View? Just write the name, not the :1.1.0 after. Also, don’t write the quotation marks.

A

androidx.recyclerview:recyclerview

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

What kind of Java object do you use to load a layout from an XML file when creating a ViewHolder? Just write the name of the class:

A

LayoutInflater

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

What is the name of the function where you set the strings for the TextViews, or EditTexts? In other words, one function is responsible for calling findViewById() to load the objects in Java, and the other function is responsible for setting the text. Which function would you call setText? Just write the name, not the ( ) parameter section.

A

OnBindViewHolder

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

What is the name of the programming pattern where you can call multiple function calls on the same object? An example would be:

object.function1()
.function2()
.function3()
.function4()

A

Builder Pattern

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

What function do you call to change the Text highlighted in the picture on an AlertDialog? Just write the name of the function that changes the text, not the parentheses ( ).

A

setTitle

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

What kind of object is used in a layout for saving space to load a Fragment? In other words, what kind of XML tag do you put in a layout to say where a Fragment will go?

A

FrameLayout

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

Which kind of Fragment Transaction is used for removing a Fragment from the screen?

A

remove

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

What is the layout folder name you should use for storing the layout for a 10” tablet?

A

layout-sw720dp

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

Write a line of code to add a Fragment whose variable name is listFragment, into a FrameLayout whose id is R.id.fragment_goes_here. You must write this using the builder pattern, where all function calls are called one after the other, with only one semicolon (;) at the end of the line. Do not put any spaces anywhere in your code:

A

getSupportFragmentManager().beginTransaction().add(-R.id.fragment_goes_here, listFragment).commit();

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

Which annotation do you put above the class that you want to store in a database?

A

@Entity

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

Which annotation do you put above a function which returns data from the database?

A

@Query

17
Q

What will be the name of the database column in this annotation:

@ColumnInfo(name=”size”)

A

size

18
Q

Write the annotation for a function in a Dao class that returns all items in the table called ChatMessages:

A

@Query(“Select * from ChatMessages”)

19
Q

What class does your abstract database class have to extend?

A

RoomDatabase

20
Q

For a Menu item, if you set the parameter showAsAction = “Always” where will the menu item show up?

A

As a picture on the toolbar

21
Q

What is the name of the function that gets called when a user clicks on a menu item?

A

onOptionsItemSelected

22
Q

What is the name of the file where you have to tell Android not to use the Actionbar, but use
Toolbar instead? (two XML tags)

< item name=”windowActionBar”>false
< item name=”windowNoTitle”>true / item>

What is the name of the file where these tags are put?

A

values/themes.xml