Terms in this set (73)
How can applications running survive a rotation change?
You CAN use the onSaveInstanceState()/onCreate () pair of methods, for tiny bits of data, but implementing a ViewModel which will preserve config changes and UI data is a much better option.
What is a headless fragment?
A fragment that doesn't have a view or layout to render.
What is the difference between an activity and a fragment?
Activity - The activity serves as the entry point for a users interaction with the app.
Fragment - You can think of a fragment as a modular section of an activity, which has its own lifecycle, receives its own input events, and which you can add or remove while the activity is running (sort of like a "sub activity" that you can reuse in different activities).
A fragment must always be hosted in an activity and the fragment's lifecycle is directly affected by the host activity's lifecycle.
To manage the fragments in your activity, you need to use FragmentManager.
What is dependency injection in Android?
Dependency injection is a style of object creation in which an objects are created by an external entity, or technique whereby one object supplies the dependencies of another object.
To but VERY SIMPLY, dependency injection is passing in an object into another object, and using "this.<object> = <paramOfObjectBeingPassedIn>" to collect the decencies to act on.
How does Dagger work?
The name "Dagger" is inspired in part by the nature of dependencies in software development. The web of dependencies that occur between objects such as Parent, Child, OtherClass, etc., create a structure called a Directed Acyclic Graph. Dagger 2 is used to simplify the creation of such graphs in your Java and Android projects.
What is MVP?
Model View Presenter
What is MVVM architecture?
Model View ViewModel
*unlike MVP, ViewModel is not required to reference a View.
Why use an anonymous class?
An anonymous inner class can be useful when making an instance of an object with certain "extras" such as overloading methods of a class or interface, without having to actually subclass a class
What is the difference between an abstract class and interface?
Abstract class can have abstract and non-abstract methods.
Interface supports multiple inheritance.
Interface has only static and final variables.
An interface can extend another Java interface only.
Members of a Java interface are always public by default.
What is object serialization?
Serialization is the conversion of an object to a series of bytes, so that the object can be easily saved to persistent storage or streamed across a communication link. The byte stream can then be deserialized - converted into a replica of the original object.
Whats the difference between a unit test and functional test?
They all refer to the same thing. Functional testing is defined as the testing of complete functionality of some application. ... You might use a unit test to test an individual function and an integration test to check that two parts of the play nice. Functional tests are on a whole another level.
Whats the difference between an implicit and explicit intent?
In this case you define an explicit intent targeting activityB and then use it to directly call it. Implicit Intents are used when you have an idea of what you want to do, but you do not know which component should be launched.
How can two distinct Android apps interact?
Permission Integration (Google Fit and Fitness App)
What are the four states of the Android Activity lifecycle?
What are the event callback methods in Android
What is the difference between serializable and parcelable? What is the best approach in Android?
The Serializable interface is simple to implement, however it's slow and creates lots of temporary objects for garbage collection.
The Parcelable interface is unique in that it uses no reflection.
The best approach is best for the app requirements. Maybe Serializable, maybe parcelable, maybe a custom serialization using writeObject() and readObject()
What are "launch modes"?
What type of launch modes are supported?
Launch modes allow you to define how a new instance of an activity is associated with the current task. You can define different launch modes in two ways:
1. Using the manifest file
2. Using intent flags
When starting an activity, you can modify the default association of an activity to its task by including flags in the intent that you deliver to startActivity()
3 common use cases for intents
Moving to another app
Moving to another activity inside the app
Passing data from one app to another
What is ADB?
Android Debug Bridge (adb) is a versatile command-line tool that lets you communicate with a device.
What is the difference between ANR and an application crash?
An ANR will occur if you are running a process on the UI thread which takes a long time, usually around 5 seconds. During this time the GUI (Graphical User Interface) will lock up which will result in anything the user presses will not be actioned.
A crash is when an exception within the app has been thrown which has not been handled.
What is the AndroidManifest.xml file used for?
The manifest does a number of things in addition to declaring the app's components, such as the following:
Identifies any user permissions the app requires, such as Internet access or read-access to the user's contacts.
Declares the minimum API Level required by the app, based on which APIs the app uses.
Declares hardware and software features used or required by the app, such as a camera, bluetooth services, or a multitouch screen.
Declares API libraries the app needs to be linked against (other than the Android framework APIs), such as the Google Maps library.
What is an Android service?
A general purpose entry point for keeping an app running in the background, like media playing, or PIP.
What is a ContentProvider and what is it typically used for?
A content provider manages a shared set of app data that you can store in the file system, in a SQLite database, on the web, or on any other persistent storage location that your app can access.
For example, the Android system provides a content provider that manages the user's contact information. As such, any app with the proper permissions can query the content provider, such as ContactsContract.Data, to read and write information about a particular person.
What is a broadcast used for in Android?
What is a broadcast receiver?
A broadcast is wrapped in an Intent object with the action string of the event. Broadcasts are sent out when system events occur, like turning off/on airplane mode.
A broadcast receiver is a component that enables the system to deliver events to the app outside of a regular user flow, allowing the app to respond to system-wide broadcast announcements, which is useful for things like timers and alarms.
Broadcast receivers are more commonly used as a gateway to other components, like scheduling a JobService to perform some work based on the JobScheduler event.
What are different ways to store data in your Android app?
Internal file storage: Store app-private files on the device file system.
External file storage: Store files on the shared external file system. This is usually for shared user files, such as photos.
Shared preferences: Store private primitive data in key-value pairs.
Databases: Store structured data in a private database.
What are Android components?
App components are the essential building blocks of an Android app. Each component is an entry point through which the system or a user can enter your app. Some components depend on others.
There are four different types of app components:
Why would you use Kotlin instead of Java?
"Kotlin has way, way more to offer than Java 8. Here is just a sampling (in no particular order)
Conditionals as expressions
The when expression
Kotlin conciseness helps to increase a cut in the lines of code by approximately 40 %
Why would you use Java instead of Kotlin?
Larger community support
Better full,clean builds (but not incremental)
What is the difference between Service and IntentService?
Service class uses the application's main thread, while IntentService creates a worker thread and uses that thread to run the service. IntentService creates a queue that passes one intent at a time to onHandleIntent(). ... IntentService implements onStartCommand() that sends Intent to queue and to onHandleIntent().
What is a sticky intent?
Intent - is a message passing mechanism between components of Android, except for Content Provider. You can use Intent to start any component.
Sticky Intent - Sticks with Android, for future broadcast listeners. For example if BATTERY_LOW event occurs then that Intent will stick with Android so that any future requests for BATTERY_LOW, will return the Intent.
Pending Intent - If you want some one to perform any Intent operation at future point of time on behalf of you, then we will use Pending Intent.
What is a coroutine?
Helps create virtual asynchronous or non-blocking threads
What is AIDL?
The Android Interface Definition Language (AIDL).
Why use ContraintLayout?
The aim of the ConstraintLayout is to help reduce the number of nested views, which will improve the performance of our layout files.
What is FrameLayout best used for?
Fragments, because it handles a single child more efficiently since there is no particular ordering, beside from gravity assignment.
Why is CardView useful for RecyclerView?
When you want to display a collection of items which might have different lengths/heights depending on their content (like pictures with descriptions and comments) or a high number of supplemental actions.
What is the difference between View.GONE and View.INVISIBLE?
INVISIBLE takes up space. GONE does not.
What is 'this' in Android?
References one step up from the current scope.
What are custom views?
When you need a completely custom layout and ConstraintLayout/LinearLayout/etc. aren't good for the app.
What are two key principles to follow in Android?
The most important principle to follow is "separation of concerns". It's a common mistake to write all your code in an Activity or a Fragment. These UI-based classes should only contain logic that handles UI and operating system interactions. By keeping these classes as lean as possible, you can avoid many lifecycle-related problems.
Another important principle is that you should drive your UI from a model, preferably a persistent model. Models are components that are responsible for handling the data for an app. They're independent from the View objects and app components in your app, so they're unaffected by the app's lifecycle and the associated concerns.
What is Gradle?
Gradle is a custom build tool used to build android packages (apk files) by managing dependencies and providing custom build logic.
How would you fix memory leak in Android?
Memory leak is when garbage is not getting collected and starts to pile up.
Anonymous classes are big culprits
Detect using Leak Canary
See where Observable Patterns can be used to help cut down on leaking
What is the observer pattern?
The Observer Pattern is a software design pattern that establishes a one-to-many dependency between objects. Anytime the state of one of the objects (the "subject" or "observable") changes, all of the other objects ("observers") that depend on it are notified
What is AsyncTask?
Why is it used?
What is a better replacement for it?
It can put processes that take more time in the background, like processing search queries.
RXJava is a better idea than AsyncTasks
What is retrofit?
This offers very easy to use REST API's.
We can use it with any serialization library, with error handling.
What is OkHTTP?
OkHttp is an open source library that is used to send http request and get response.
What is Android testing in Espresso?
Espresso is a testing framework for Android to make it easy to write reliable user interface tests.
Why is the main thread sometimes called the UI thread?
The Main thread, that is responsible for handling the UI events like Draw, Listen and receive the UI events.
Ans also it is responsible for interact with running components of the UI toolkit for the corresponding application that belongs to.
What does 'static' mean in Java?
static means that the variable or method marked as such is available at the class level. In other words, you don't need to create an instance of the class to access it.
Can a constructor be inherited?
Constructors are not members of classes and only members are inherited. You cannot inherit a constructor
What does a constructor do?
A constructor is a special method that is called whenever an object is created using the new keyword.
Are objects passed by reference or value in Java?
How are Array and ArrayList objects different?
Array is a fixed sized list that can contain primitives and objects.
ArrayList is a flexibly sized list that can only contain objects.
What is a ViewGroup and how is just a View different?
ViewGroup is a invisible container of other views (child views like TextView, Button, etc) and other viewgroups. Eg: LinearLayout is a viewgroup which can contain other views in it. ViewGroup is a special kind of view which is extended from View as its base class.
What is a dialog in Android?
A dialog is a small window that prompts the user to make a decision or enter additional information. A dialog does not fill the screen and is normally used for modal events that require users to take an action before they can proceed.
What is an input type in Android?
It helps with validation and changing the keyboard types when inputting different types of information.
How can I persist data in an Android device?
What is DDMS in Android?
DDMS. The Dalvik Debug Monitor Server (DDMS) is a more advanced debugging tool from the SDK that has also been integrated into Android Studio. This tool is able to monitor both a real device and the emulator. To open the DDMS perspective navigate to Tools.
This would help see if you have memory leaks.
What is the support library? Why was it introduced?
When developing apps that support multiple API versions, you may want a standard way to provide newer features on earlier versions of Android or gracefully fall back to equivalent functionality. Rather than building code to handle earlier versions of the platform, you can leverage these libraries to provide that compatibility layer.
If you use include in layouts, can you override properties?
Can every property be overridden?
Yes If the <include> tag does not include both layout_width and layout_height
How do you communicate between fragments and activities?
To allow a Fragment to communicate up to its Activity, you can define an interface in the Fragment class and implement it within the Activity.
What is SharedPreferences used for?
SharedPreferences is an API from Android SDK to store and retrieve application preferences. SharedPreferences are simply sets of data values that stored persistently.
An example would be dark mode.
Whats the difference between an Observable, Single, and Completable in RXJava?
Single represent Observable that emit single value or error.
Completable represent Observable that emits no value, but only terminal events, either onError or onCompleted
What is the viewholder pattern?
Part of RecyclerView, Adapter, ViewHolder components for making a list.
If you have a BroadcastReceiver defined, the method onReceive will run on which thread?
The main/ui thread. Always.
What is ORM? How does it work?
ORM converts data between type systems that are unable to coexist within relational databases and OOP languages." It allows them to avoid the struggle of developing queries by concatenating strings or handling the connections with database manually.
How do you implement GCM into your app?
By implementing firebase.
Whats the difference between a method and a function?
A method is similar to a function, but is internal to part of a class.
What is a normal permission?
Normal permissions cover areas where your app needs to access data or resources outside the app's sandbox, but where there's very little risk to the user's privacy or the operation of other apps. For example, permission to set the time zone is a normal permission.
What is a signature permission?
The system grants these app permissions at install time, but only when the app that attempts to use a permission is signed by the same certificate as the app that defines the permission.
What is a dangerous permission?
Dangerous permissions cover areas where the app wants data or resources that involve the user's private information, or could potentially affect the user's stored data or the operation of other apps. For example, the ability to read the user's contacts is a dangerous permission.
What is LiveData?
LiveData is an observable data holder class. Unlike a regular observable, LiveData is lifecycle-aware, meaning it respects the lifecycle of other app components, such as activities, fragments, or services. This awareness ensures LiveData only updates app component observers that are in an active lifecycle state.
OnClickListener is a LiveData object;
The Room persistence library supports observable queries, which return LiveData objects.
What are advantages to using LiveData?
LiveData follows the observer pattern and ensures your UI matches your data state.
No memory leaks, because observers are bound to Lifecycle objects and clean up after themselves when their associated lifecycle is destroyed.
No crashes due to stopped activities
If a lifecycle becomes inactive, it receives the latest data upon becoming active again, so data is always up to date.
What is an intent filter?
Intent filters are a very powerful feature of the Android platform. They provide the ability to launch an activity based not only on an explicit request, but also an implicit one.
For example, an explicit request might tell the system to "Start the Send Email activity in the Gmail app". By contrast, an implicit request tells the system to "Start a Send Email screen in any activity that can do the job."