pt1 Flashcards

1
Q

What is the purpose of the ‘src’ folder in an Android project structure?

A

Contains your stub Activity file and all other source code files

The stub Activity file is stored at src/your/package/ActivityName.java.

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

What types of files are stored in the ‘res’ folder?

A

Application resources, such as:
* Drawable files
* Layout files
* String values
* Animation files

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

What is the function of the ‘mipmap’ folder?

A

Allows inclusion of different versions of the app’s launcher icon optimized for each screen density.

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

What does the ‘assets’ folder contain?

A

Arbitrary raw asset files.

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

What is the difference between the ‘assets’ directory and the ‘asset’ folder?

A

Access method differs.

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

What do the ‘menu’ folder XML files define?

A

Application menus.

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

What is the purpose of the ‘AndroidManifest.xml’ file?

A

Describes the nature of the application and each of its components.

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

What are the two ‘build.gradle’ files used for?

A

Level project config and Level module config.

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

What does ProGuard do?

A

Optimizes and obfuscates your code.

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

What is the first step to build an Android application?

A

Start Android Studio.

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

What is a common good practice when naming the main activity?

A

Name it ‘MainActivity’.

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

What is the purpose of the ‘Activity’ component in Android?

A

Focuses on a single thing a user can do with a visual user interface.

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

True or False: Services in Android have a visual interface.

A

False.

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

What are Broadcast Receivers used for?

A

Receive and react to broadcast announcements.

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

What class do you extend to create a Broadcast Receiver?

A

BroadcastReceiver.

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

What is the role of Content Providers in Android?

A

Allow data exchange between applications.

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

What class do you extend to create a Content Provider?

A

ContentProvider.

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

Fill in the blank: Activities are the ______ component of most applications.

A

basic

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

What method is used to make a View or ViewGroup visible in an Activity?

A

Activity.setContentView()

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

What can you do with existing services in Android?

A

Bind to them and control their operation.

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

What are examples of broadcasts that a Broadcast Receiver might handle?

A

Low battery, power connected, shutdown, time zone changed.

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

What is the only way to transfer data between applications in Android?

A

Using Content Providers.

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

What object do other applications use to access data from a Content Provider?

A

ContentResolver.

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

What is an Activity in Android?

A

An application component that represents one window and one hierarchy of views.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
25
How is an Activity typically defined?
As a Java class, usually one Activity in one file.
26
What does an Activity typically have?
A UI layout defined in one or more XML files.
27
What method is used to inflate the layout in an Activity?
setContentView()
28
What is the purpose of the Activity lifecycle?
To manage the states an Activity can be in during its lifetime.
29
List the states of an Activity during its lifecycle.
* Created (not visible yet) * Started (visible) * Resumed (visible) * Paused (partially invisible) * Stopped (hidden) * Destroyed (gone from memory)
30
What triggers state changes in an Activity?
User action, configuration changes, or system action.
31
What is the first lifecycle callback method called?
onCreate()
32
What does onCreate() do?
Performs static setup: creates views, binds data to lists.
33
True or False: onCreate() is called multiple times during an Activity's lifetime.
False
34
What follows the onCreate() method in the Activity lifecycle?
onStart()
35
What is the purpose of onStart()?
Called when the Activity is becoming visible to the user.
36
What is the difference between onRestart() and onStart()?
onRestart() is called after an Activity has been stopped, immediately before it starts again.
37
What does onResume() indicate?
The Activity is now interacting with the user and is at the top of the Activity stack.
38
What should be done in onPause()?
Commit unsaved changes, stop animations, and free resources.
39
What happens in onStop()?
The Activity is no longer visible to the user.
40
What is the final lifecycle callback before an Activity is destroyed?
onDestroy()
41
What is the purpose of the finish() method?
To terminate the Activity.
42
What does the OnBackPressedDispatcher do?
Handles back button presses in the Activity.
43
Fill in the blank: The Activity lifecycle includes states triggered by _______.
[user action, configuration changes, system action]
44
What does the isFinishing() method check?
Whether the Activity is finishing.
45
What is the purpose of the 'src' folder in an Android project structure?
Contains your stub Activity file and all other source code files ## Footnote The stub Activity file is stored at src/your/package/ActivityName.java.
46
What types of files are stored in the 'res' folder?
Application resources, such as: * Drawable files * Layout files * String values * Animation files
47
What is the function of the 'mipmap' folder?
Allows inclusion of different versions of the app’s launcher icon optimized for each screen density.
48
What does the 'assets' folder contain?
Arbitrary raw asset files.
49
What is the difference between the 'assets' directory and the 'asset' folder?
Access method differs.
50
What do the 'menu' folder XML files define?
Application menus.
51
What is the purpose of the 'AndroidManifest.xml' file?
Describes the nature of the application and each of its components.
52
What are the two 'build.gradle' files used for?
Level project config and Level module config.
53
What does ProGuard do?
Optimizes and obfuscates your code.
54
What is the first step to build an Android application?
Start Android Studio.
55
What is a common good practice when naming the main activity?
Name it 'MainActivity'.
56
What is the purpose of the 'Activity' component in Android?
Focuses on a single thing a user can do with a visual user interface.
57
True or False: Services in Android have a visual interface.
False.
58
What are Broadcast Receivers used for?
Receive and react to broadcast announcements.
59
What class do you extend to create a Broadcast Receiver?
BroadcastReceiver.
60
What is the role of Content Providers in Android?
Allow data exchange between applications.
61
What class do you extend to create a Content Provider?
ContentProvider.
62
Fill in the blank: Activities are the ______ component of most applications.
basic
63
What method is used to make a View or ViewGroup visible in an Activity?
Activity.setContentView()
64
What can you do with existing services in Android?
Bind to them and control their operation.
65
What are examples of broadcasts that a Broadcast Receiver might handle?
Low battery, power connected, shutdown, time zone changed.
66
What is the only way to transfer data between applications in Android?
Using Content Providers.
67
What object do other applications use to access data from a Content Provider?
ContentResolver.
68
What is a view in Android?
Everything you see is a view.
69
Name some examples of views in Android.
* Button * EditText * Slider * CheckBox * RadioButton * Switch
70
What is the purpose of the Android Studio layout editor?
It provides a visual representation of XML.
71
What are the two tabs available in the XML layout file in Android Studio?
* Design * Text
72
What is the purpose of the Palette pane in the Android Studio layout editor?
To provide components for designing the layout.
73
What are the attributes of a view defined in XML?
android:=""
74
Fill in the blank: In XML, a TextView can be defined as <TextView android:id="@+id/show_count" android:layout_width="______" .../>
match_parent
75
What is the relationship between dp and dpi?
1dp = 1px on a screen with 160dpi.
76
What is the conversion formula for converting dp to px?
px = dp * (dpi / 160)
77
What does sp stand for in Android measurements?
Scale-independent Pixels.
78
What is the default relationship between sp and dp?
1SP = 1DP.
79
How is screen density classified in Android?
* ldpi ~120dpi * mdpi ~160dpi * hdpi ~240dpi * xhdpi ~320dpi * xxhdpi ~480dpi * xxxhdpi ~640dpi
80
What are common widgets used in Android development?
* Button * TextView * EditText * ImageView * CheckBox * RadioButton * WebView * ListView * Spinner * RecyclerView
81
What is a ViewGroup in Android?
A container that holds child views.
82
Name three common layout classes in Android.
* ConstraintLayout * LinearLayout * TableLayout
83
What is the purpose of the orientation attribute in LinearLayout?
It indicates whether the layout is a row or a column.
84
What does the weight attribute in LinearLayout determine?
The distribution of space among child views.
85
What is the purpose of the gravity attribute in LinearLayout?
It determines how a control aligns on the screen.
86
How do you create a LinearLayout in Java code?
LinearLayout linearL = new LinearLayout(this);
87
Fill in the blank: In Java code, to set the orientation of a LinearLayout, you use linearL.setOrientation(______);
LinearLayout.VERTICAL
88
What is the significance of the root view in a view hierarchy?
The root view is always a ViewGroup.
89
True or False: Actual Pixels (px) should be used for layout measurements in Android.
False
90
What is ConstraintLayout in Android?
A flexible and powerful way to create complex layouts, allowing for better control over UI elements positioning and sizing.
91
What is one advantage of using ConstraintLayout?
Easier to create responsive designs that adapt to different screen sizes and orientations.
92
How does ConstraintLayout improve app performance?
By maintaining a flat view hierarchy, reducing nested layouts.
93
What are Guidelines in ConstraintLayout?
Proper guidelines for setting constraints ensure consistent and predictable behavior of UI elements.
94
What is the purpose of Chains in ConstraintLayout?
To align and distribute UI elements, contributing to a visually appealing layout design.
95
What do Barriers in ConstraintLayout facilitate?
The creation of complex and responsive layouts.
96
Define a Constraint in ConstraintLayout.
A rule or connection that defines how a view is positioned and sized relative to other views or the parent layout.
97
What are the types of relative Constraints?
* Parent Constraint * Sibling Constraint
98
What do horizontal constraints define?
The horizontal position of a view.
99
What do vertical constraints define?
The vertical position of a view.
100
What is Bias in ConstraintLayout?
Defines the bias for a view along an axis, determining space taken up by each side of the constraint.
101
How can you create a chain of views in ConstraintLayout?
By allowing views to share a common axis for alignment and distribution.
102
What are Guidelines in ConstraintLayout?
Invisible lines that views can be constrained to for easier design layouts.
103
What is the purpose of Flow in ConstraintLayout?
To create a flow of views with specific wrap modes.
104
How many methods are there to create constraints in ConstraintLayout?
Five methods.
105
What does the method 'Infer constraints' do?
Automatically creates all constraints for views.
106
What is the drag-and-drop method for creating constraints?
Using anchors to create constraints by dragging and dropping.
107
What does 'wrap-content' mean in ConstraintLayout?
A function that sizes a view to fit its content.
108
What is the significance of a bias value of 0.5?
Positions the view in the center horizontally.
109
What happens when the text of a focused button changes in relation to a barrier?
The width of the button changes, causing the barrier to move and other buttons to adjust accordingly.
110
What is the function of the 'match-parent' attribute?
Makes a view expand to match the size of its parent.
111
True or False: ConstraintLayout allows for nested layouts.
False
112
Fill in the blank: A view must have at least one _______ constraint and one vertical constraint.
horizontal