Questions Flashcards
How Do You Manage Resources for Different Screen Sizes?
Android devices come in a variety of sizes and resolutions. When you’re building your app, it’s important to decide which of the many models you will support. Once you’ve made this decision, there are three common approaches you can take to make sure your app supports all screen sizes:
Use view dimensions.
Create several layouts, depending on the screen.
Provide your images and resources as bitmaps.
Of course, you may also use a combination of these approaches in your app.
The Android developers website covers this in detail in the article Support different screen sizes.
What Is Android Jetpack?
Jetpack is a suite of libraries released by Android in 2018. Jetpack’s libraries provide code that works across the many Android devices currently in use. This makes it easy for developers to adhere to best practices!
33) What is the importance of Default Resources?
When default resources, which contain default strings and files, are not present, an error will occur and the app will not run. Resources are placed in specially named subdirectories under the project res/ directory.
21) How are escape characters used as attribute?
Escape characters are preceded by double backslashes. For example, a newline character is created using ‘\n
What Are Activities and Fragments?
An activity is a single thing the user can do within your app. The activity class takes care of creating a window in which you place your UI. A fragment is a small piece of functionality within this activity.
Since 2018, Android recommends creating single-activity apps. An app should consist of fragments within a host activity
What Is an Intent?
Intents are messaging objects that trigger actions from other components. These target components can include services and activities.
8) What are the four essential states of an activity?
Active – if the activity is at the foreground
Paused – if the activity is at the background and still visible
Stopped – if the activity is not visible and therefore is hidden or obscured by another activity
Destroyed – when the activity process is killed or completed terminated
48) What is an action?
In Android development, an action is what the intent sender wants to do or expected to get as a response. Most application functionality is based on the intended action.
Other Libraries?
In the Android world, you’ll encounter many libraries in addition to those in Jetpack. Your interviewer may ask about these. Here are some of the most common:
Libraries for network requests: Retrofit, GraphQL
Libraries for images: Picasso
Dependency Injection: Dagger
Reactive Programming: RXJava and RXKotlin
Describe two kinds of intent?
An explicit intent specifies a particular destination for fulfillment. You can direct your intent to an external app. But an explicit intent commonly targets another component within your app. When using an explicit intent, your code must provide the name of the target app or component.
Implicit Intent
An implicit intent does not specify the target component. Instead, it states an action to perform. The Android system directs the intent to an external app capable of fulfilling it. For example, if your app needs to send an email, the Android system will select options from the email apps installed on the device. The user can select the desired email app.
What Are Unit Tests? How Do You Do Them in Android?
.
Unit tests run locally. Since they aren’t run on a device, they don’t have access to any Android framework library. It’s possible to use libraries that allow you to call Android framework methods from unit tests, however these libraries substitute only simulate device behavior. The preferred libraries are either JUnit or Mockito.
The ability to design and implement unit testing is usually a requirement for mid-senior to senior levels. If you want to learn how to do this, here are some resources:
JUnit is the standard java library for testing, which is usually coupled with AndroidX Test. This is covered in our tutorial Test-Driven Development Tutorial for Android: Getting Started.
Mockito is another popular open-source testing framework. You can learn more about it in our tutorial Android Unit Testing with Mockito
Instrumentation Tests
Instrumentation tests are quite similar to unit tests but depend on a device or simulator to run. Since instrumentation tests are run on device, you have access to the Android device libraries. The two libraries mentioned above, JUnit and Mockito, are also used for instrumentation tests.
UI Tests
UI tests simulate a user’s interactions with your UI. The most popular library for testing is Espresso. You can learn about UI testing in our tutorial
) Do all mobile phones support the latest Android operating system?
Some Android-powered phone allows you to upgrade to the higher Android operating system version. However, not all upgrades would allow you to get the latest version. It depends largely on the capability and specs of the phone, whether it can support the newer features available under the latest Android version.
45) What is a Sticky Intent?
A Sticky Intent is a broadcast from sendStickyBroadcast() method such that the intent floats around even after the broadcast, allowing others to collect data from it.
41) Is it possible to use or add a fragment without using a user interface?
Yes, it is possible to do that, such as when you want to create a background behavior for a particular activity. You can do this by using add(Fragment,string) method to add a fragment from the activity.
11) What items are important in every Android project?
These are the essential items that are present each time an Android project is created:
AndroidManifest.xml build.xml bin/ src/ res/ assets/
39) What is a visible activity?
A visible activity is one that sits behind a foreground dialog. It is actually visible to the user, but not necessarily being in the foreground itself.
30) What is the AndroidManifest.xml?
This file is essential in every application. It is declared in the root directory and contains information about the application that the Android system must know before the codes can be executed.
What Are Layouts in Android?
Layouts define the structure of the UI of an app. They consist of View and ViewGroup objects, arranged hierarchically. There are different types of layout:
Constraint Layout
Linear Layout
Relative Layout
Because this is one of the most complex concepts in Android, we cover layouts in both a video course, Beginning Android Layouts, and a tutorial, ConstraintLayout Tutorial for Android: Getting Started. Please review them if you need a better understanding of this important subject!
22) What is the importance of settings permissions in app development?
Permissions allow certain restrictions to be imposed primarily to protect data and code. Without these, codes could be compromised, resulting to defects in functionality.
31) What is the proper way of setting up an Android-powered device for app development?
The following are steps to be followed prior to actual application development in an Android-powered device:
- Declare your application as “debuggable” in your Android Manifest.
- Turn on “USB Debugging” on your device.
- Set up your system to detect your device.
38) What is a Fragment?
e.
A fragment is a part or portion of an activity. It is modular in a sense that you can move around or combine with other fragments in a single activity. Fragments are also reusabl
42) How do you remove icons and widgets from the main screen of the Android device?
To remove an icon or shortcut, press and hold that icon. You then drag it downwards to the lower part of the screen where a remove button appears.
What Is View Binding?
View binding replaces findViewById. It uses binding classes to do this. These classes contain references to all views that have an ID in the corresponding layout.
27) What are the different states wherein a process is based?
There are 4 possible states:
foreground activity
visible activity
background activity
empty process