Android App Generalities, Android Studio, Fragments

0.0(0)
studied byStudied by 0 people
0.0(0)
full-widthCall Kai
learnLearn
examPractice Test
spaced repetitionSpaced Repetition
heart puzzleMatch
flashcardsFlashcards
GameKnowt Play
Card Sorting

1/111

encourage image

There's no tags or description

Looks like no tags are added yet.

Study Analytics
Name
Mastery
Learn
Test
Matching
Spaced

No study sessions yet.

112 Terms

1
New cards

Is the Android API the same across all versions of Android?

No.

2
New cards

Is Android open or closed source?

Open.

3
New cards

What do Android applications run on top of?

The Android API which is meshed with the System API.

4
New cards

What is part of the Android Open Source Project (AOSP) as opposed to brand-specific functionalities?

Android Framework, Generic Kernel, and Generic Kernel Image (GKI) Modules.

5
New cards

What is the hierarchy of the Android Platform architecture?

System Apps

Java API Framework

Native C/C++ Libraries, Android Runtime

Hardware Abstraction Layer (HAL)

Linux Kernel

6
New cards

What is the hierarchy of layers in the Android Application architecture?

UI Layer: Displays application data for user to interact with.

Domain Layer: Optional layer to encapsulate business logic.

Data Layer: Application data and business logic.

7
New cards

What is LiveData?

Data like Strings, Lists, etc. that need to be observable (update automatically like in JavaFX).

8
New cards

What is business logic?

It refers to what is done behind the scenes with state changes.

In easier terms, it is the logic that glues your models together.

9
New cards

How is Android Application architecture generally set up?

According to the MVVM design pattern.

M: Model (Data logic)

V: View (Activity, Fragment)

VM: ViewModel (Business logic [LiveData])

10
New cards

Do Android devices run .class and .jar files?

No. They run Android runtime which is optimized for performance.

11
New cards

Is Kotlin is interoperable with Java?

Yes.

12
New cards

What is an Android Virtual Device (AVD)?

An emulator to model an actual Android device.

13
New cards

Can you simulate games or location in AVD?

Not with the same speed or consistency.

14
New cards

What is the Android project structure?

manifests directory: App settings.

source directory: Controllers.

res directory: drawable (images), layout (views), mipmap (icons), values (constants) directories.

Gradle Scripts: Application configuration and dependency management (build.gradle).

15
New cards

What languages can be used to build Android apps?

Kotlin, Java, C++.

16
New cards

What is an Android Package (APK)?

An archive file of your code. Basically a JAR file for Android devices.

17
New cards

Does Android function as a single user Linux system?

No, it is multi user Linux system. Each application is a different user. Each application is assigned a unique Linux user ID.

18
New cards

How many Linux processes are run per application?

One. Each process has its own virtual machine (VM).

19
New cards

What's the difference between desktop and mobile application processes?

Mobile applications automatically shut down other application processes when memory is low.

20
New cards

By default, does each Android application have access ONLY to the Components that it requires to do its work?

Yes.

21
New cards

Do Android applications directly control their application process' lifetime?

No. The Android system handles this.

22
New cards

Is it possible to arrange for two applications to share the same Linux user ID?

Yes. This allows one application to access the other application's data.

23
New cards

What are the essential building blocks of an Android application?

Components.

24
New cards

What are the four types of Components?

1. Activities (UIs)

2. Services

3. Broadcast receivers

4. Content providers (sources of data)

25
New cards

Do all Components share the same lifecycle?

No.

26
New cards

What is the difference between how applications are started on desktop versus mobile?

Mobile applications don't always begin in the same place. Sharing a PDF via email on mobile goes directly to a "compose email" activity and loads the PDF, for example.

27
New cards

Does Android initiate code in main()?

No. Android applications can be started through Activities or other components.

28
New cards

What does an Activity do?

It provides the window in which the app draws its UI.

29
New cards

Are you good to run your application after simply adding an Activity?

No. You must register your Activity in the manifest file.

30
New cards

How does the Android Activity lifecycle work?

Example:

You open an app: onCreate() → onStart() → onResume()

You get a call: onPause() → onStop()

You return to the app: onRestart() → onStart() → onResume()

You swipe away the app: onPause() → onStop() → onDestroy()

<p>Example:</p><p>You open an app: onCreate() → onStart() → onResume()</p><p>You get a call: onPause() → onStop()</p><p>You return to the app: onRestart() → onStart() → onResume()</p><p>You swipe away the app: onPause() → onStop() → onDestroy()</p>
31
New cards

What is the back stack?

A stack of Activities in order of when it was opened.

32
New cards

What happens to the last Activity when a new Activity starts?

The last activity is stopped and placed in the back stack.

33
New cards

What happens when the user completes the current Activity and presses the back button?

The current Activity is popped from the back stack and destroyed. The previous Activity is then resumed.

34
New cards

What are lifecycle callback methods?

onCreate(), onResume(), onDestroy(), etc. in your Activity class.

35
New cards

Where do you declare how your Activity behaves when the user leaves or enters the Activity?

In the lifecycle callback methods.

36
New cards

When is the onCreate() callback method called?

When an Activity is created.

You should fill it with logic like initializing class-scope variables that exist during the duration of the Activity.

37
New cards

Is the onCreate() callback method optional?

No. You need to define what happens upon Activity startup.

38
New cards

How does the onCreate() callback method receive previously saved states?

Through the Bundle savedInstanceState parameter.

onCreate(Bundle savedInstanceState)

39
New cards

When is the onStart() callback method called?

Immediately after the onCreate() callback method.

It runs the code to display the UI.

40
New cards

When is the onResume() callback method called?

Immediately after the onStart() or onPause() callback method, depending on whether the application was just created or is just being resumed.

You should fill it with logic like initializing Components released during the onPause() callback method.

41
New cards

When is the onPause() callback method called?

When the Activity is no longer in the foreground (e.g. the application is swiped away).

You should fill it with logic like pausing operations that would waste battery life (e.g. pause location tracking).

42
New cards

When is the onStop() callback method called?

When the Activity is no longer visible to the user (e.g. a new Activity covers the entire screen).

You should fill it with logic like pausing operations that would waste battery life (e.g. pause location tracking).

43
New cards

When is the onDestroy() callback method called?

When the Activity is about to exit.

You should fill it with logic like releasing all resources not yet released by previous callback methods.

44
New cards

What are Services?

Services provide long-running operations in the background without displaying a UI (e.g. playing sounds or network connectivity).

45
New cards

What are Broadcasts?

System messages like battery low, alarm, screen turned off, etc.

46
New cards

What are Broadcast Receivers?

A component that lets the system deliver events (like a battery low notification) to the app, even ones that are not running).

47
New cards

What happens when Activities, Services, and Broadcast Receivers are not implemented correctly?

The system can kill the application's process while it is doing important work.

48
New cards

What are the two ways applications receive broadcasts?

1. Receivers declared in the manifest file.

2. Receivers registered in the Context.

49
New cards

What are Content Providers?

A component that manages a set of app data so it can be stored in a storage location.

50
New cards

How do you start new Activities?

startActivity()

OR

startActivityForResult() (when a result needs to be passed back)

Regardless of which is chosen, and Intent object is passed.

51
New cards

Do Activities overlap when starting and stopping?

Yes.

Example:

Activity A => onPause()

Activity B => onCreate() => onStart() => onResume()

Activity A => onStop()

52
New cards

What is an Intent?

An object specifying what to do with a Component.

53
New cards

What is the difference between Intents for Activities, Services, and Broadcast Receivers?

Activities and Services: The Intent defines the action to perform (like ACTION_SEND).

Broadcast Receivers: The Intent defines the announcement being broadcast.

54
New cards

Since Android applications are separate processes associated with different user IDs, how does an application activate Components in other applications?

Using Intent objects.

55
New cards

What is the passive data structure holding an abstract description of an action to be performed?

An Intent.

56
New cards

What are the fundamental use cases for Intents?

Starting an Activity, Service, or delivering a Broadcast.

57
New cards

Do Intents for Activities represent a single screen or multiple screens?

A single screen.

58
New cards

What do you do if you need information back from an Activity?

Use the startActivityForResult() method instead of the startActivity() method.

59
New cards

What is the difference between an explicit and implicit Intent?

Explicit: Specifies which Component satisfies the Intent.

Implicit: Specifies the action, data, and category from which the Android system will determine which Component satisfies the Intent.

You can think of an implicit Intent as giving some information to the Android system which consequently chooses the best Component to match the information.

60
New cards

What is an Intent filter?

is an expression in the manifest file that specifies the category that the Component matches with.

For example, an EmailInboxActivity Component should be specified to be a potential candidate for incoming email Intents.

61
New cards

What is the primary information contained in an Intent?

Name of Component: Class name (EmailService, EmailActivity, etc.).

Action: A String specifying the action to perform (ACTION_VIEW, ACTION_SEND, etc.).

Data: The URI referencing the data.

Category: A String specifying the category of the Intent (CATEGORY_EMAIL, CATEGORY_LAUNCHER, etc.)

Extra: Key-value pairs for additional information.

62
New cards

What is the extra portion of an Intent?

Data to share between Activities. Specifically, a Bundle object is shared between two Activities.

63
New cards

What kind of data types can you share between Intents in the extra portion?

Primitive data types like ints.

Objects like String.

64
New cards

How do you pass data using the extra portion of an Intent?

Activity 1:

public static final String key = "message";

intent.putExtra(key, bundle);

startActivity(intent);

Activity 2:

Intent intent = getIntent();,

int bundle = intent.getIntExtra(Activity1.key, 0);

OR

String bundle = intent.getStringExtra(Activity1.key);

OR

Thing bundle = (Thing) intent.getSerializableExtra(Activity1.key);

OR

Thing bundle = (Thing) intent.getParcelableExtra(Activity1.key);

65
New cards

How do you start a Component using an explicit Intent?

Intent explicitIntent = new Intent(this, SomeService.class);

explicitIntent.setData(Uri.parse(fileUrl));

startService(expicitIntent);

66
New cards

How do you start a Component using an implicit Intent?

Intent implicitIntent = new Intent();

implicitIntent.setAction(Intent.ACTION_SEND);

implicitIntent.putExtra(Intent.EXTRA_TEXT, textMessage);

67
New cards

What is a Context?

A Singleton class linked to the Application which holds all Activities running inside it. It has access to system resources and services as well as to application operations like starting Activities, broadcasting and receiving Intents, etc.

For example, context.startActivity(intent) is completely valid syntax.

68
New cards

What is the manifest file?

An XML file that primarily informs the Android system about Components' existence. It is important to specify Components here, otherwise the application won't use them.

It also declares permissions required, features needed (like Bluetooth or multi-touch), and APIs used.

69
New cards

How are Components specified in the manifest file?

(specify and other things here)

For the other Components, , , and are the appropriate tags.

70
New cards

What are application resources?

Resources separate from the source code like images, audio files, etc.

71
New cards

What is the benefit of application resources?

It makes it easy to update various features of your application without modifying source code.

72
New cards

What is a resource ID?

An ID that corresponds to a resource (like an image).

You can access this ID by using R.id.imagename in Java.

73
New cards

What is a View?

Similar to a Node in JavaFX, a View is an element in the UI that the user can see and sometimes interact with.

74
New cards

What is a ViewGroup (layout)?

Similar to a Pane in JavaFX, a ViewGroup is a container that defines the layout structure for Views and other ViewGroup objects.

75
New cards

Do you have to use XML to describe the application layout?

No. You can instantiate ViewGroups and Views in the Java source code.

76
New cards

Why should you use XML for describing the UI over instantiating ViewGroups and Views in the Java source code?

It separates presentation and styling from code, as well as makes dynamic adaptation to differing screen sizes easier.

77
New cards

How many root elements can there be in a layout?

Exactly one View or ViewGroup object.

78
New cards

Where should the XML view files be loaded from?

The onCreate() callback method.

setContentView(R.layout.main.fxml);

79
New cards

What are two basic attributes of Views?

1. Location (x-y coordinate pairs)

2. Dimensions (width and height)

80
New cards

What unit is used for location and dimensions?

Density-independent pixel (dp).

81
New cards

What is Toast?

A simple non-clickable popup notification.

Context context = getApplicationContext();

Toast toast = Toast.makeText(context, "Hello World", Toast.LENGTH.SHORT);

toast.show();

82
New cards

What is AlertDialog?

A popup message that displays on the screen, where various dialog option choices to answer can be added.

AlertDialog.Builder alert = new AlertDialog.Builder(this);

alert.setMessage("Hello World").setTitle("Title");

AlertDialog dialog = alert.create();

dialog.show();

83
New cards

What are some common ViewGroup subclasses?

ConstraintLayout: Allows you to constrain Views to a vertical and horizontal offset from other Views or the side of the Layout.

LinearLayout (horizontal and vertical): Basically a JavaFX VBox/HBox.

FrameLayout: Basically a JavaFX StackPane.

TableLayout: Basically a JavaFX GridPane.

TableRow: Individual row objects in TableLayout.

Space: Empty container used to create space.

84
New cards

What is Logcat?

The Logcat window displays system messages (like when garbage collection occurs) and messages that you add to your application with the Log class.

85
New cards

What are the Log methods?

Log.e(String, String): Error log.

Log.w(String, String): Warning log.

Log.i(String, String): Information log.

Log.d(String, String): Debug log.

Log.v(String, String): Verbose log.

86
New cards

What is a Bundle?

A class that, when instantiated, can store a collection of data stored as key-value pairs. These can be given to an Intent so that a new Activity has the data. This way, a Singleton is unnecessary to hold data.

87
New cards

What shape do all Views have?

A rectangular area on the screen.

88
New cards

What is the prefix for stylizing Views?

"android:"

Example:

89
New cards

What is the difference between XML layout_height/layout_width values "match_parent" and "wrap_content"?

match_parent: As big as its parent View.

wrap_content: Just big enough to enclose its content.

Example:

android:layout_height="wrap_content"

90
New cards

What is a TextView?

Similar to a Label in JavaFX, a TextView is a View that displays text.

91
New cards

What is an EditText?

Similar to a TextField in JavaFX, an EditText is a View that allows a user to enter text.

Useful attributes:

android:inputType="text/phone/number/datetime/numericPassword"

92
New cards

How do you access application resources from /res in Java source code?

R.id

R.layout

R.drawable

R.array

R.string

R.color

R.style

93
New cards

What common Views in Android Studio have identical names to Nodes in JavaFX?

Button

RadioButton (which uses RadioGroup, not ToggleGroup)

CheckBox (which uses isChecked(), not isSelected()

ImageView

ListView

94
New cards

What ImageView attribute is used to get an image resource from /res/drawable?

"src"

XML:

android:src="@drawable/nameofimage"

Java:

imageView.setImageResource(R.drawable.cola);

95
New cards

What is the Adapter class?

An Adapter object accesses data in an array or other data type and creates a View for it.

96
New cards

What is the ArrayAdapter class?

One of the implementations to get data and provide a View for it.

97
New cards

How does an ArrayAdapter object create a View to be displayed to a user?

By default, it just calls Object.toString() on each element in the array, placing it in a TextView.

98
New cards

What common Views use an ArrayAdapter or other Adapter object?

Subclasses of AdapterView, namely:

Spinner

ListView

RecycleView also uses adapters.

Example:

view.setAdapter(adapter);

99
New cards

What is the Spinner class?

Similar to a ComboBox in JavaFX, a Spinner is a View that displays items and allows a user to choose an item.

You should use an ArrayAdapter to display items.

100
New cards

What is the ListView class?

Similar to a ListView in JavaFX, a ListView displays a collection of vertically scrollable Views.