Android Flashcards

1
Q

What is Android?

A

Android is an open-source operating system based on Linux, mainly focused on mobile, IoT and standalone devices.

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

What are the 4 main components of an Android App?

A

Activities
Content Providers
Services
Broadcast Receivers

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

What is an Activity?

A

It is one of the main Android components,
It is an entry point which makes the interaction with the user,
It is able to contain a view (layout) and fragments
and it has its own lifecycle which are a set of methods
that tell us the status of the Activity, for example:
onCreate(), onStart(), onResume(), onPause(), onStop(), onDestroy() and onRestart().

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

What is the lifecycle of an Activity?

A

It is a set of methods or functions that tell us the status of the Activity. These methods or functions are: onCreate(), onStart(), onResume(), onPause(), onStop(), onDestroy() and also onRestart()

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

Activity Life cycle description:

A

onCreate - called when activity is first created.
onStart - called when activity is becoming visible to the user.
onResume - called when activity will start interacting with the user.
onPause - called when activity is no longer in the foreground.
onStop - called when activity is no longer visible to the user.
onRestart - called after your activity is stopped, prior to start.
onDestroy - called before the activity is destroyed.

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

What is the difference between onCreate() and onStart() method?

A

The onCreate() method is called just one time and onStart() method could be called many times.

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

How can you share information between activities?

A

We can share information using bundles and passing[pasing] them through[thru] Intents. You need to instantiate[instanshieit] the Intent class, then pass the data on the putExtra() method before doing startActivity(intent).

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

What is a Fragment?

A

A Fragment is a portion of an activity, a Fragment can’t live on its own[oun] and it has to be contained in an Activity to exist, but has its own lifecycle which are a set of methods that tell us the status of the Fragment, for example:
onAttached(), onCreate(), onCreatedView(), onViewCreated(), onActivityCreated(), onStart(), onResume(), onPause(), onStop(), onDestroyView(), onDestroy(), onDetach().

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

What is the lifecycle of a Fragment?

A

Answer: It is a set of methods that tells us the states of the Fragment. These methods are:
onAttached - It’s the first method that it’s going to be called inside a Fragment, because it letting us know that this fragment it’s been attached to an activity
onCreate - it’s called to create the fragment without view
onCreatedView - Called for the fragment to draw the UI for the first time. It returns the layout or can return null if the fragment doesn’t provide UI
onViewCreated - This inherits to onCreateView but the particular reason to use it is because you can initialize some components that are on the UI.
onActivityCreated* - This method indicates that the activity is onCreate() has completed. And you can use this method to initialize something that is needed on the fragment that depends upon the activity’s onCreated.
onStart - This method is called once the fragment gets visible
onResume - The fragment is active and ready for the user interaction
onPause - It’s called when the system indicates that the user is leaving the fragment
onStop - It’s called when the fragment is not longer visible
onDestroyView - It’s called the Fragment view is destroyed but not the instance
onDestroy - It’s called the fragment instance is destroyed.
You can do a final clean up of the fragment’s state, but it is not guaranteed to be called by the Android platform. **
onDetach - This method notify that the fragment has been disassociated from the hosting activity

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

What is the difference between Activity and Fragment?

A

Both have their own lifecycle.
Fragments need to be attached to an Activity.
The activity is able to work without a Fragment.
Activity can have multiple fragments.
Google recommends the usage of fragments when possible since fragments are lighter to create than an activity.

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

Can an activity contain many fragments?

A

Yes, It is able to do that. For example you can use the Single Activity pattern where you have only one activity and many fragments for the screens, you can use fragmentManager or the Navigation component library from Jetpack for the navigation and pass information between fragments with SafeArgs.

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

How can you share information between Fragments?

A

We can share information by using the FragmentManager (bundles), a shared ViewModel with lived data , Navigation Component library (safeArgs) with Jetpack, or using interfaces through the host activity.
Note: As a best practice, do not directly communicate a fragment with another.

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

What is a Service?

A

A Service is one of the main Android components, it is used to represent either an application’s desire to perform a longer-running operation while not interacting with the user or to supply functionality for other applications to use.
There are 3 different types of services:
Background Service: This service is used for executing a long-running task without[widout] notifying the user that a task is running in the background. Google is not recommending this service because it is a good practice to notify the user what is running in the background.
Foreground Service: This service is used for executing a long-running task but it has to be executed with a notification and this notification has to show the progress of the task or just notify the user that something is running in the background.
Bound Service: It works as Server-Client where the server is the bound[baund] service and the client could be any application component with a context (Activity). This architecture enables communication between different[difrent] processes/apps (same service attached to different Activities from different Applications). And it is finished when all the components unsubscribe from the service.

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

Does a service run on the background thread?

A

No, It runs on the Main thread by default.

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

What is an IntentService?

A

It is a service which is used when you need to run a long-running task on a background thread instead of main thread, once the IntentService finishes the task it will be stopped. This service type is deprecated, it is better to use WorkManager since it allows us to schedule background tasks depending on device constraints like battery, network connection and system restarts.

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

What is the difference between a Service and an IntentService?

A

Service runs on the main thread and stops when you call the stopService method, IntentService runs on background thread and stops when the task is finished.

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

What is a BroadcastReceiver?

A

A broadcastReceiver is another main Android component, that is able to receive events from the Android system such as when the device starts charging, when the device has internet connection or the system boots up. It is a best practice to subscribe to these events using an Activity and perform some action when the event occurs, instead of declaring them on the manifest.

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

What is a ContentProvider?

A

A ContentProvider is another main Android component, that gives to the application the capability to manage access to data stored by itself, stored by other apps and provide a way to share data between applications. An example of this would be accessing the device contacts from your application.

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

What is the difference between ContentProvider and Database?

A

ContentProvider is the contract or interface that exposes the data from an application that usually needs to be stored in some place, we could use a Database to store and get the information that the ContentProvider is going to use

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

What is an Intent?

A

Is an abstract description of an operation to be performed by the Android system. Intent could contain an action, category and/or data.
There are two types :
Explicit: You specify the android component that is going to resolve the action. Like navigating to a specific activity using startActivity with the class name.

Implicit: In this case, you don’t specify the target, and instead you let the Android system pick one for you based on the intent action and the intent-filters declared on the installed apps manifest. Or if you use an Intent Chooser you can let the User decide. For example, opening the gallery or sending an email using Intent.Action.Text/Email/PickImage/etc.

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

How does your data flow in your architecture, for example while launching an API call (MVVM/Clean Architecture)?

A

<Acting I: mmm alright, actually for that I have some scenario that I usually give to junior developers, so they understand the flow for a network call through different layers>
Let’s say:
1. We want to implement a login screen, we have user credentials and a button to make the request.
2. And we are using; Clean Architecture, MVVM and Repository pattern for the project.

<Act>
Now, when the user clicks the login button->
1. We receive button action with setOnClickListener
2. This executes a viewmodel method
3. Then the viewmodel
a. Applies some business logic, like validating the inputs are not empty
b. If all is fine, then it launches a coroutine for the repository call with the user credentials
4. The repository
a. Has a remote dataSource with the retrofit implementation
b. Serializes the request using GSON/Moshi/any parser
c. Makes the call using a suspend function through the API interface
5. When the server responds, the datasource will deserialize the response to a Data Model
6. Pass it back to the repository and the ViewModel
7. Then the ViewModel
a. validates the response
b. map it to a Domain Model,
c. It updates a LiveData that the UI is observing
8. Finally the user can visualize the result of their action (error login, or navigate to new screen)
</Act>

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

What do you like/dislike about Kotlin?

A

I like Koltin better because it provides many different features that makes the code more efficient and readable, like:
- Extension functions: provides a way to extend functionality without needing to inherit from a class, and we can use it directly in objects.
- Scope Functions: We can execute a block of code within an object context and make the code more idiomatic using english words like Let and Apply.
- Null safety: Help us prevent crashes because we need to always check for
- null abi-li-ty.
- Coroutines: Gives us an easy way to make multithreading operations.
And many other features that make me like Kotlin.
So this is why it is hard to find something that I dislike about Kotlin, if I had to say anything it would be that Kotlin’s community is not as big as Java’s (for now).

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

What are the advantages/features of Kotlin?

A

Kotlin has many features, like
● Null safety: This is the main advantage/feature that helps us to prevent the headache (hed-ek) when programming with Java: The null pointer exception.
● Extension functions: I really like this one, since we can add functionality without needing to create another class and inherit just to add functionality, a really cool feature.
● Supports full Java Interoperability: That means if we have an old Java codebase, we can take our time to migrate Kotlin gradually, or create new modules in Kotlin without problems.
We have more features, such as:
● Scope functions
● Coroutines
● Higher Order functions and Lambda Expressions
● It’s based on Functional Programming
● And all of these features make Kotlin more efficient, readable and easier to understand as a programming language.

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

What is Null-Safety?

A

Null safety is the main advantage/feature that helps us to prevent the headache (hed-ek) when programming with Java: The null pointer exception. Kotlin offers some operators to handle this, for example:
● Safe calls operator (?): It is used in case you want to check the null condition and if the expression is null then by default it will return null or else it will return the value.
● Elvis operator (? :): This operator simplifies the validation of a value that could be null. This can guarantee that an expression won’t return a null value, as you will provide a non-nullable value if the provided value is null.
● The not-null assertion operator (!!): As the Kotlin’s documentation says, this is for NullPointerExcetion-lovers. This operator converts any value to a non-null type and throws an exception if the value is null. But that is returning Java.
We have some other features, but those are the most important. (Safe cast and Collections of a nullable type)

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

How do you handle it?

A

Kotlin offers some operators to handle this, for example:
● Safe calls operator (?): It is used in case you want to check the null condition and if the expression is null then by default it will return null or else it will return the value.
● Elvis operator (? :): This operator simplifies the validation of a value that could be null. This can guarantee that an expression won’t return a null value, as you will provide a non-nullable value if the provided value is null.
● The not-null assertion operator (!!): As Kotlin’s documentation says, this is for NullPointerExcetion-lovers. This operator converts any value to a non-null type and throws an exception if the value is null. But that is returning Java.
We have some other features, but those are the most important. (Safe cast and Collections of a nullable type)

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

When do you use null assertion (!!)?

A

Never. Google doesn’t recommend using it, but maybe some Java implementation or API requires it, and if this is the case, we need to use a try-catch to protect against exceptions.

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

What is a Data class?

A

The purpose of a Data Class is to simplify classes whose main purpose is to hold data. For this class, the compiler automatically generates:
- copy() function,
- equals() and hashCode() pair,
- toString() form of the primary constructor,
- And componentN() functions

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

What is an Extension function?

A

An extension function provides a better way of extending a class without modifying the original class. It is important to say that by defining an extension do not actually modify the classes they extend, only making new functions callable with the dot-notation on variables of this type.

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

What are the Scope functions?

A

Scope functions are whose sole purpose is to execute a block of code within the context of an object. When you call such a function on an object with a lambda expression provided, it forms a temporary scope. In this scope, you can access the object without its name.

let , run , with , apply , also

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

What is a Sealed class?

A

Sealed classes are used for representing restricted class hierarchies, when a value can have one of the types from a limited set, but cannot have any other type. Sealed classes can have fields and methods defined in them, including both abstract and implemented functions.

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

What are inline and noinline functions?

A

When using lambdas, the extra memory allocations and extra virtual method call, introduce some runtime overhead.

When using inline functions, the compiler inlines the function body. That is, it substitutes the body directly into places where the function gets called.
When using inline functions, there is no extra object allocation and no extra virtual method calls.
However, we should not overuse the inline functions, especially for long functions since the inlining may cause the generated code to grow quite a bit.

By default, all lambdas passed to an inline function would be inlined, too. However, we can mark some of the lambdas with the noinline keyword to exclude them from inlining.

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

What is a high order function?

A

High order function is one which can accept a function as a parameter or can return a function.We can pass a lambda expression as a parameter which is essentially anonymous functions that we can treat as values. Finally, in High-Order functions we have two types of functions which can be passed:
- a function which returns Unit,
- And a function which returns any of the value integer, string etc.

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

What is an object keyword in kotlin?

A

Object represents a single static instance, and can never have any more or any less than this one instance.
Object expressions create objects of anonymous classes, that is, classes that aren’t explicitly declared with the class declaration.
This is useful for various techniques, including singleton objects and simple packaging up of functionality for encapsulation.

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

What is a Companion object?

A

Companion objects are singleton objects whose properties and functions are tied to a class but not to the instance of that class. So, basically like the “static” keyword in Java.

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

What is the difference between ‘val’ and ‘var’?

A

Val
- Is a read-only local variable (can be assigned a value only once)
- is assigned one time on runtime execution.
Var
- Is a mutable variable (I mean, can be reassigned)
So, var can be re-assigned and val can not be.

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

What is the difference between val and const val?

A

Val is assigned in runtime and Const val in compile time.

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

What is the difference between ‘lazy’ and ‘lateinit’?

A

Lateinit
- It is used with VAR
- Reserves a space in memory
- And you promise Kotlin that you will initialize it before you use it, or else the app will crash (Throws: Property not initialized)
Lazy
- It is used with VAL
- Creates a wrapper class and delegates the value to it (by Lazy)
- Used usually if getting the value requires expensive computation.
- It will assign the value when you read it for the first time.

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

How do you do a migration from Java to Kotlin? What do you need to look out for?

A

Migrate Whole Project
1. We want to do a meeting with the team, to plan and prioritize what modules we need to migrate first
Migrate Module
2. Make sure we have the documentation from the module we want to migrate or create it if necessary.
3. Start by taking smaller to bigger and complex classes to migrate.
Migrate Class
4. We take a Class and pass it through the IntelliJ Idea migration tool to convert Java to Kotlin
5. It is not perfect, but at least we have a starting point.
6. We now check for optimizations in the resultant code with the Kotlin features (scope functions, extensions, when, if, for statements, etc)
7. Also it is important to review Null cases, because Java doesn’t work with this unless you annotate with @Nullable or @Non-Nullable.
8. Finally we can run the class tests to make sure it still works as expected.

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

Do you need to add anything if you want to extend a class in Kotlin?

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

How do you create a Singleton?

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

How do you create static methods?

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

What is the superclass in Kotlin?

A

The superclass is Any.

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

When to use ‘lateinit’ and when ‘lazy’?

A

by lazy use it when you must waiting a event to initialize the val
and this val cant not be null. Late init use when yo dou want initialize a var and you assign which type is

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

Can a ‘lateinit’ variable be nullable?

A

no

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

What are the advantages of Kotlin?

A

null safety, less verbosal , clearer code

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

Difference between ? and !!?

A

safety call verify if a variable is null and double bang you affirm your variable is not null. Also you never must use double bang

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

When would you use ‘!!’?

A

never

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

When would you use ‘!!’

A

: there are simple classes used as data containers and do not encapsulate any additional logic. Simply put, Kotlin’s solution enables us to avoid writing a lot of boilerplate code.

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

How do you do a Java to Kotlin migration?

A
  1. Open the . java file.
  2. Copy all the code to the clipboard.
  3. Create the corresponding Kotlin. kt file.
  4. Paste the code. (Click “Yes” when it asks for your permission to convert the code.)
  5. If needed, check the class and update it.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
50
Q

What are the best practices for migrate code?

A

● Change Java models to Kotlin first.
● Use default parameters and partialize annotation.
● While converting utils classes to extension function, use the same class name.
● To avoid changing the client code, use Kotlin JVM Annotation.
● Avoid loops with collection extensions.
● Kotlin recommends using “if” for binary for three or more options.

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

What’s the use for an open modifier?

A

when you need that a class have inheritance because , kotlin class created by default are final

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

What are the different layouts in Android?

A

We have ConstraintLayout, LinearLayout, RelativeLayout, FrameLayout and TabLayout.

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

What is the ConstraintLayout?

A

This layout allows you to create large and complex layouts that are responsive. It is similar to RelativeLayout because all views are laid out according to relationships between views and the parent layout but ConstraintLayout is more flexible and easier to use with Android Studio’s Layout Editor.
To define the view’s position, you must add at least one horizontal and one vertical, if you missed it, you will get a compilation error.

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

What is the RelativeLayout?

A

This layout allows you to position the views or components by relations between components and parent

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

What is the difference between ConstraintLayout and LinearLayout?

A

LinearLayout aligns the views or components one by one horizontally or vertically and ConstraintLayout uses relations to position and size the views or components and you can easily edit with the LayoutEditor.

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

What is the difference between ConstraintLayout and RelativeLayout?

A

Basically, ConstraintLayout comes to update RelativeLayout. They look similar but the big difference is that the ConstraintLayout uses a lower cost , and is faster than RelativeLayout since it only does one pass to calculate the views position.
Constraint layout has many attributes and tools that allow us to better position the content, like vertical/horizontal bias, barriers, guidelines and chains.
Also ConstraintLayout is optimized to use the Android Layout editor.

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

What is a CustomView?

A

It is when you create a class and extend from View in order to create a totally new view Overriding the OnDraw method and OnMeasure.
Like one I created for Gaszen, it was a specific circular progress bar that they wanted. I had to draw it using Paths with circles and arcs. Provide some methods to set the progress and colors.

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

What is a CompoundView?

A

It is when you create a class that extends from a ViewGroup (usually FrameLayout), where we inflate a group of views that we want to reuse. We can also provide methods to set/access the information.

59
Q

What is the difference between CustomView and CompoundView?

A

CompoundView is when you have a group of views that you reuse by inflating them in a class that extends from a ViewGroup. On the other hand, a custom view refers to a class that you extend from View in order to draw it manually using Canvas in the methods onDraw and onMeasure.

60
Q

What is Android Jetpack?

A

It is a set of libraries for Android development created by Google, some of these libraries are LiveData, Databinding, viewBinding, ViewModel, Room, WorkManager, Hilt, CameraX, Navigation component and Compose.

61
Q

What are the Android Jetpack libraries?

A

LiveData, Databinding, viewBinding, ViewModel, Room, WorkManager, Hilt, CameraX, Navigation component and Compose.

62
Q

What is a ViewModel?

A

It is a class that is responsible for preparing and managing the data for an Activity or a Fragment. It handles the communication between the view (Activity / Fragment) and the business logic classes.
It is used also to retain data on view when there is configuration change (for example: when you rotate the device)

63
Q

Why does ViewModel survive the configuration change?

A

Because ViewModel is always created in association with a scope and will be retained as long as the scope is alive.

64
Q

What is DataBinding?

A

It is a library that allows you to bind UI components in your layouts (XML) to data sources in your app.
It is really easy to implement, you just need to enable it on the Gradle.Build file, then implement it on the XML and finally on the UI (activity or fragment).
(other answer) The Data Binding Library is a support library that allows you to bind UI
components in your layouts to data sources in your app using a declarative format
rather than programmatically.

65
Q

What are the different types of DataBinding?

A

There are One-way and Two-way binding, One-way is just for updating the view and Two-way is for getting the value from the XML or updating the value on the view.

66
Q

What is LiveData?

A

It is an observable data holder class. It is not like a regular observable because It is lifecycle-aware which means it respects the lifecycle of other app components such as activities, fragments and service.
It is used for allowing communication between the View (Activity, Fragment, etc) and the source of the data (ViewModel).

67
Q

What are the advantages of using LiveData?

A

The main advantage is you do not need to manually cancel subscriptions between View and ViewModel.

68
Q

What are the disadvantages of using LiveData?

A

he main disadvantage is that it does not come with a toolkit for combining streams of data or managing threads, like Rx does.

69
Q

What is a MediatorLiveData?

A

It is a LiveData subclass which may observe other LiveData objects and react on OnChanged events from them.
It is used when you need to merge the emissions from 2 LiveData objects.

70
Q

In general terms, What are the practices that make an application secure?

A

The use of signature-based permissions.
Ask for credentials before showing sensitive information. For example you can ask for a PIN/ password/Pattern or a biometric credential.
Use permissions with content providers.
Use the HTTPS request if your application communicates with a web service that has a certificate.
Use Webviews carefully, don’t allow users to navigate to sites that are outside of your control
Store sensitive data safely, you can use Jetpack Security that gives us a way to encrypt files or data in Sharedpreferences.
You can use SQLCipher to encrypt your data in your database.

71
Q

What is Proguard?

A

It is a shrinker, optimizer and obfuscator, recently called R8. It detects and safely removes unused classes, fields, methods and attributes and also removes unused resources.
It shortens the name of classes and members, which results in reduced DEX file sizes.
It inspects and rewrites your code to further reduce the size of your app’s DEX files.

72
Q

What are the common issues with Proguard?

A

If you are using reflection, there are some classes that proguard does not detect as they are used, so Proguard removes those classes. You have to establish rules in proguard or with the use of Dagger you can solve this.
Another issue is when you are using the property name sensible parser, for example GSON library, if you do not use the serializedName, Proguard could change the name of the attributes, thus the attribute will not match, you can solve this by using serializedName or you can use -keepclassmembers

73
Q

What is SQLCipher?

A

It is a SQLite extension that adds an encryption layer to SQLite. The encryption is pretty strong, it is using AES-256 which is a standard in the industry.

74
Q

How do you implement SQLCipher?

A

You just need to implement the library on the Gradle file, then you have to instantiate a SupportFactory class, write a passphrase as a parameter and in the builder of the Room database you have to add the factory.

75
Q

What is Jetpack Security?

A

It is a library that provides the implementation of the best practices related to reading and writing data, as well as key creation and verification.
It provides the level of security that is appropriate for banking and chat apps.
This library uses a 2-part system for key management, a keyset that contains the keys to encrypt a file and a masterkey that encrypts all keysets.
This library includes 2 libraries which are EncryptedFile and EncryptedSharedPreferences.

76
Q

What is EncryptedFile?

A

It provides custom implementations of FileInputStream and FileOutputStream, these provide secure read and write operations from file streams using the Streaming Authenticated Encryption with Associated Data.

77
Q

What is EncryptedSharedPreferences?

A

It wraps the SharedPreferences class and automatically encrypts keys and values, key are encrypted using a deterministic encryption algorithm and values are encrypted using AES-256 and are non deterministic.

78
Q

What are some of the encryption methods in Android?

A

They are symmetric encryption, asymmetric encryption, hashing, digital signature, end to end encryption, elliptic-curve cryptography and HMAC.

79
Q

What is Symmetric encryption?

A

is a type of encryption where only one key (a secret key) is used to both encrypt and decrypt electronic information

There are two types of symmetric encryption algorithms:
1. Block algorithms.
2. Stream algorithms.

80
Q

What is Asymmetric encryption?

A

is when you use two keys for the process.
● The public key used for encryption is available to everyone but the private key is not disclosed.
● This encryption method is used in everyday communication over the internet.

81
Q

What is Hashing?

A

Hashing is the process of transforming any given key or a string of characters into another value

82
Q

What is Digital signature?

A

A digital signature is a mathematical technique used to validate the authenticity and integrity of a message

83
Q

What is End to end encryption?

A

End-to-end encryption (E2EE) is a method of secure communication that prevents third parties from accessing data while it’s transferred from one end system or device to another

84
Q

What is Elliptic curve cryptography?

A

is a key-based technique for encrypting data. ECC focuses on pairs of public and private keys for decryption and encryption of web traffic.

85
Q

What is HMAC?

A

Hash-based Message Authentication Code (HMAC) is a message authentication code that uses a cryptographic key in conjunction with a hash function. Hash-based message authentication code (HMAC) provides the server and the client each with a private key that is known only to that specific server and that specific client.

86
Q

What are the testing advantages?

A

rapid feedback, early failure detection, safer code refactoring and stable development velocity.

87
Q

What is testing in Android?

A

Testing is a very important part of the app development process, because you can verify your app’s correctness, functional behavior and usability before you release it publicly.

88
Q

What are test categories ?

A

Small 70%,medium 20%, large 10%

89
Q

Which libraries have you used for Dependency Injection?

A

Dagger, Koin and most recently Hilt (You can mention that is something new that you are learning and practicing).

90
Q

What is dependency injection?

A

Dependency injection, is a design pattern that abstract the creation logic of dependencies and provides it to classes that need them. It helps us to make testing and mocking dependencies easier. It follows the dependency inversion principle.

91
Q

What is Dagger 2?

A

Dagger 2 is a dependency injection framework. It is based on the Java Specification Request. It uses code generation and is based on annotations. The generated code is very relatively easy to read and debug.
Dagger 2 uses the following annotations:
● @Module and @Provides: define classes and methods which provide dependencies
● @Inject: request dependencies. Can be used on a constructor, a field, or a method
● @Component: enable selected modules and used for performing dependency injection
Dagger 2 uses generated code to access the fields and not reflection. Therefore it is not allowed to use private fields for field injection.

92
Q

What is Hilt?

A

Hilt defines a standard way to do dependency injection (DI) in your application by providing containers for every Android class in your project and managing their lifecycles automatically for you.

93
Q

Which libraries have you used before for multithreading?

A

Coroutines, RxJava and Asynctask

I am using coroutines in my current project, but I have used RxJava and many years ago Asynctask.

94
Q

What is RxJava?

A

: It is an API for asynchronous programming with Observable streams, It is a combination of the best ideas from the observer pattern, the iterator pattern, and functional programming.
RxJava is easy for multi-threading, it has simple error handling and it avoids the callback hell.

95
Q

What is an Observable?

A

It is the source that emits the data to the Observers, the Observers need to subscribe first to get the data emitted.

96
Q

What is Cold and Hot Observable?

A

Cold Observable is the one that needs an Observer subscribed to start emitting data, and the Hot Observable is the opposite. It is emitting data even if there is no Observer subscribed.

97
Q

What is a Scheduler?

A

It is component that tells the Observable or Observer on which thread they should run, we can use the method subscribeOn() to tell the Observable on which thread it should run and we can use the method observeOn() to tell the Observable on which thread they should emit the data. There are different schedulers for example:
Schedulers.io() -> This one is used generally for network requests and database requests.
Schedulers.computation() -> This one is used for performing CPU-intensive operations like processing huge data or bitmap processing.
AndroidSchedulers.mainThread() -> This one is used for bringing back the execution to the main thread so UI updates can be done when required.

98
Q

What is Disposable?

A

It is the instance created after an Observer subscribes to an Observable.
We can unsubscribe to an Observable by calling the dispose() method on the Disposable instance.

98
Q

What is Disposable?

A

It is the instance created after an Observer subscribes to an Observable.
We can unsubscribe to an Observable by calling the dispose() method on the Disposable instance.

99
Q

What is a CompositeDisposable?

A

It is a class which is able to store many disposables in it, let say we have multiple calls happening, if would need to prematurely dispose, you need to dispose every disposable, but with CompositeDisposable you can add many disposables and if you need to dispose all at once, you just need to call dispose() method once.

100
Q

What is a map?

A

is used for transformation only, but flatMap() is used for both transformation and flattening.

101
Q

What is a FlatMap?

A

is the combination of a map and a flat operation i.e, it applies a function to elements as well as flatten them

102
Q

What is a ConcatMap?

A

concat combines a number of observables streams and sequentially emits all values from every given input stream.
operator is basically a combination of two operators - concat and map. The map part lets you map a value from a source observable to an observable stream.

does not subscribe to the next observable until the previous completes

103
Q

What is the difference between map and FlatMap?

A

Both map and flatMap can be applied to a Stream<T> and they both return a Stream<R>. The difference is that the map operation produces one output value for each input value, whereas the flatMap operation produces an arbitrary number (zero or more) values for each input value.</R></T>

104
Q

What is the difference between FlatMap and ConcatMap?

A

Flat map uses merge operator while concatMap uses concat operator.

105
Q

What are the types of observables?

A

Observable
● Flowable
● Single
● Maybe
● Completable

106
Q

What are Coroutines?

A

A coroutine is an instance of suspendable computation. It is conceptually similar to a thread, in the sense that it takes a block of code to run that works concurrently with the rest of the code.

107
Q

What are the different states in a Job?

A

new ,active ,completing, cancelling,cancelled ,completed

108
Q

Flows

A

Flow is a better way to handle the stream of data asynchronously that executes sequentially.
Flow lets you implement the observer pattern: a software design pattern that consists of an object (a.k.a. observable, producer, source, emitter) that maintains a list of its dependents, called observers (subscribers, collectors, receivers, etc.), and notifies them automatically of any state changes.

Observables can be either hot or cold. Hot observables send or emit data even if no one is watching them and cold observables emit data only if they have an active observer. By default, Kotlin flows are cold.

109
Q

Flow builders

A

There are the following basic ways to create a flow:
● flowOf(…) functions to create a flow from a fixed set of values.
● asFlow() extension functions on various types to convert them into flows.
● flow { … } builder function to construct arbitrary flows from sequential calls to emit function.
● channelFlow { … } builder function to construct arbitrary flows from potentially concurrent calls to the send function.
● MutableStateFlow and MutableSharedFlow define the corresponding constructor functions to create a hot flow that can be directly updated.

110
Q

Flow constraints

A

All implementations of the Flow interface must adhere to two key properties described in detail below:
● Context preservation.
● Exception transparency.
These properties ensure the ability to perform local reasoning about the code with flows and modularize the code in such a way that upstream flow emitters can be developed separately from downstream flow collectors. A user of a flow does not need to be aware of implementation details of the upstream flows it uses.

111
Q

What is Firebase?

A

Google Firebase is a Google-backed application development software that enables developers to develop iOS, Android and Web apps. … The data is synced across all clients in real time and is still available when an app goes offline.

112
Q

What are the steps to implement Firebase on a project?

A

1.Register your app with Firebase
2. Add a Firebase configuration file
3.Add Firebase SDKs to your app

113
Q

What are the steps to implement Firebase on a project?

A

1.Register your app with Firebase
2. Add a Firebase configuration file
3.Add Firebase SDKs to your app

114
Q

What is a push notification?

A

A push notification is a message that pops up on a mobile device. App publishers can send them at any time; users don’t have to be in the app or using their devices to receive them.

115
Q

What is the push notification’s flow with Firebase?

A

● App server sends a data message to FCM server
● The FCM message is delivered to the client app
● User opens the app

116
Q

What is Firestore?

A

Cloud Firestore is a NoSQL document database that lets you easily store, sync, and query data for your mobile and web apps - at global scale.

117
Q

What is the superclass in Java?

A

The superclass is Object

118
Q

What are the access modifiers in Java?

A

public , private

119
Q

What is SOLID?

A

Answer: It is design principles intended to make software more understandable, flexible and maintainable.
The “S” is for Single Responsibility Principle: Every module, class or method should have a responsibility over a single part. We should not have objects which know too much and have unnecessary behavior. So, a class will do only one job. Thus, this class should have only one reason to change.
The “O” is for Open-Closed Principle: Open means that we can add new features to class and Closed means that base features of class should not be able to change.
The “L” is for Liskov Substitution Principle: We should be able to use subclasses instead of the parent classes which class they have extended, without the need to make any changes in our code. In simple words, a child class must be substitutable for the parent class.
The “I” is for Interface Segregation Principle: As we know, interfaces provide layers of abstraction that simplify code and create barriers which are preventing coupling to dependencies. Classes should not implement interfaces which they are not going to use.
The “D” is for the Dependency Inversion Principle: It tells us about the coupling between the different classes or modules. Higher level classes should not be dependent on lower level classes. Both should be dependent on abstractions.

120
Q

What is Inheritance?

A

Inheritance is the procedure in which one class inherits the attributes and methods of another class. The class whose properties and methods are inherited is known as the Parent class. The class that inherits the properties from the parent class is the Child class. And the child class can have its own properties and methods.

121
Q

What is Inheritance?

A

Inheritance is the procedure in which one class inherits the attributes and methods of another class. The class whose properties and methods are inherited is known as the Parent class. The class that inherits the properties from the parent class is the Child class. And the child class can have its own properties and methods.

122
Q

What is Polymorphism?

A

It allows us to perform a single action in different ways. In other words, polymorphism allows you to define one interface and have multiple implementations.
There are 2 types of polymorphism: Compile time Polymorphism and Runtime Polymorphism.

Compile-time polymorphism is also known as static polymorphism, it is to achieve overloading that is when there are multiple functions with the same name but different parameters.

Runtime polymorphism is achieved by method overriding; this occurs when a derived class has a definition for one of the member functions of the base class.

123
Q

What is Abstraction?

A

Using simple things to represent complexity. We all know how to turn the TV on, but we don’t need to know how it works in order to enjoy it. In Java, abstraction means simple things like objects, classes and variables represent more complex underlying code and data. This is important because it lets you avoid repeating the same work multiple times.

124
Q

What is Encapsulation?

A

The practice of keeping fields within a class private, then providing access to those fields via public methods. Encapsulation is a protective barrier that keeps the data and code safe within the class itself. We can then reuse objects like code components or variables without allowing open access to the data system-wide.

125
Q

What is HashMap?

A

hash table based implementation of Java’s Map interface. A Map, as you might know, is a collection of key-value pairs.

126
Q

What is an interface class?

A

In this interface class you define methods. Unlike a class, an interface never implements methods; instead, classes that implement the interface implement the methods defined by the interface. Another thing to mention is a class can implement multiple interfaces.

127
Q

What is an abstract class?

A

An abstract class is a class that is declared abstract —it may or may not include abstract methods

128
Q

What is the difference between an interface and abstract class?

A

you can use only one abstract inheritance class and you can implement many interfaces has you want

129
Q

Can an abstract class be instantiated?

A

no

130
Q

Difference between object and class:

A

Object is an instance of a class and a Class is a blueprint or template from which objects are created.

131
Q

What is a design pattern?

A

reusable solution to a commonly occurring problem within a given context in software design

132
Q

What are the design patterns?

A

Creational : Factory Method (Class) , Abstract Factorty ,Build , Prototype , Singleton (Object)
Structural : Adapter (Class) , Adapter (Object), Bridge , Composite, Decorator , Facade , Flyweight , Proxy (Object)
Behavioral : Interpreter, Template Method (Class), Chain of responsability, Command , iterador , Mediator , Memento , Observer , State , Strategy , Visitor

133
Q

What architectural design patterns have you used?

A

When I started programming in Android, I implemented a MVC pattern (in 2015), then I noticed that this pattern was difficult to test, because we had the majority of code in the Activity, so then, some years after, I started migrating the code to MVP pattern. In this pattern we had to separate the logic with the application’s view and communication through a contract between the MVP components, and allow us to improve our testing issues. Finally, in my last works, I have had to migrate from MVP to MVVM and also start new modules directly using MVVM. With MVVM we don’t have contracts, I mean the view doesn’t know the ViewModel implementation and the ViewModel updates the UI through observers using Kotlin features like coroutines.

134
Q

What is MVVM?

A
  • MVVM is an architecture pattern whose main objective is the separation of concerns.
  • Views display the UI and inform about user actions.
  • The ViewModel gets the information from your Data Model, applies the necessary
    operations and exposes the relevant data to your Views.
  • The ViewModel exposes backend events to the Views so they can react accordingly.
  • The Model, also known as the DataModel, retrieves information from your backend
    and makes it available to your ViewModels
135
Q

What are the advantages of MVVM?

A

● MVVM facilitates easier parallel development of a UI and the building blocks that power it.
● By handling all data manipulation to ViewModels, unit testing becomes very easy since they don’t have any reference to the Views
● MVVM abstracts the View and thus reduces the quantity of business logic required in the code behind it.

136
Q

What are the disadvantages of MVVM?

A

● MVVM may be too complex for applications with simple UI.
● While data bindings can be declarative and nice to work with, they can be harder to debug than imperative code where we simply set breakpoints.

137
Q

What is the difference between MVC, MVP and MVVM? (comparison table)

A

https://www.geeksforgeeks.org/difference-between-mvc-mvp-and-mvvm-architecture-pattern-in-android/

138
Q

What is the MVP pattern?

A

MVP stands for “Model-View-Presenter”, is an architectural pattern which is mostly used for building user interfaces. In MVP, the presenter assumes the functionality of the “middle-man”. In MVP, all presentation logic is pushed to the presenter. MVP advocates separating business and persistence logic out of the Activity and Fragment.

139
Q

What is Clean Architecture?

A

Clean architecture is a software design philosophy that separates the elements of a design into ring levels. An important goal of clean architecture is to provide developers with a way to organize code in such a way that it encapsulates the business logic but keeps it separate from the delivery mechanism.
The main rule of clean architecture is that code dependencies can only move from the outer levels inward. Code on the inner layers can have no knowledge of functions on the outer layers.

Commonly in mobile application development, we find only 5 layers: presentation, use cases (sometimes found as Interactors), domain, data and framework.
- Presentation: It is the layer that interacts with the user interface. Presentation layer usually consists of the Android user interface (activities, fragments, views) and presenters or view models, depending on the presentation pattern you choose to use.
- Use cases (interactors): These are mainly the actions that the user can trigger. These can be active actions (the user clicks a button) or implicit actions (the App navigates to a screen). You can even remove this layer and include them inside the Domain layer.
- Domain: Also known as the business logic. These are the rules of your business and contain all the business models.
- Data: In this layer there is an abstract definition of the different data sources, and how they should be used. A repository pattern is usually used here, which, for a given request, is able to decide where to find the information.
- Framework: It basically encapsulates the interaction with the framework, so the rest of the code can be agnostic and reusable in case you want to develop the same application for another platform.

140
Q

What is the repository pattern?

A

The repository pattern is a strategy for abstracting data access.The idea with this pattern is to have a generic abstract way for the app to work with the data layer without being bothered with if the implementation is towards a local database or towards an online API.
The repository pattern has two purposes; first it is an abstraction of the data layer and second it is a way of centralizing the handling of the domain objects.

141
Q

Explain step by step a network connection with retrofit using mvp or mvvm:

A

● Create a retrofit instance with the builder
○ pass the base url and pass to retrofit builder
○ Create the okhttp client and pass to retrofit builder
○ Create the converter factory and pass to retrofit builder
● Provide the api passing a retrofit instance for create it
● Create the interface with suspend fun for call to service
● Create the data class to catch the response from network call
● Create the repository interface and repository class implementation , then you extend the class impl from repository interface
● Create mutable live data and live data in the viewmodel
● Create a function in your viewmodel in case of use mvvm
To implement
● If you are using a mvvm pattern inject the repository in the viewmodel , if you are using mvp pattern inject in the model
● Use the viewmodel scope for launch the dispatcher.Io for make the network call
● Use the your api and call your suspend function inside the dispatcher io
● Pass the data received in your io dispatcher to your live data
● Call your viewmodel in your function
● Use your viewmodel in your view for observe the live data from your view model

142
Q

What is jetpack compose?

A

Jetpack Compose is Android’s modern toolkit for building native UI. It simplifies and accelerates UI development on Android. Quickly bring your app to life with less code, powerful tools, and intuitive Kotlin APIs.