Week3 Android Coursera
Week3 Android Coursera
To use the Android emulator, you will need to download it first. This reading will guide you through
setting up emulator software in Android Studio.
Although the set-up process has been captured with a Mac device, the same instructions apply to
Windows users.
You can download the emulator from the SDK manager located in the top right corner of the Android
Studio welcome screen.
Select Menu Icon > SDK Manager. Then, from the settings window, choose Android emulator. Click
Apply and Android Studio will download the emulator for you.
An Android emulator cannot run on your computer without a virtualization tool for hardware
acceleration. Fortunately, Windows 10 comes preloaded with Hyper-V, which is one of the best
virtualization tools in the market.
For Mac users, you can discover Hyper-V’s status on your computer by running the following
command on your terminal.
1
sysctl kern.hv_support
If your computer supports it, the command output will look as follows when turned on showing the
kern.hv_support value returning 1:
If Hyper-V is not installed on your computer, then Android Studio allows you to install HAXM through
its SDK manager. HAXM is another hardware acceleration tool. HAXM is downloaded and installed
through the same window you used to download the Android emulator.
Wait for the installations to complete, and then restart your computer and Android Studio.
Now, select Tools > AVD Manager (for Android Virtual Device) and explore the virtual devices.
Downloading a virtual device
There’ll be a default virtual device in your AVD manager when you download the Android emulator.
However, you can download the device of your choice that has a different screen size or other
specifications to test your application for your specific purpose or on a larger scale.
When you open the AVD manager, you can locate the button for creating a new virtual device at the
top left corner.
Each virtual device comprises some hardware and software configurations. The system image of a
virtual device represents its software components.
When you set out to create a new virtual device, you’ll have to determine its hardware first. This is
where you select settings like the screen size, screen resolution, screen pixel density and RAM. You
can define the hardware from scratch or use the default hardware options offered by Android Studio.
In the hardware selection menu, you’ll also get to see a Play Store icon beside some of the
hardware choices. The system image of these devices will have a Play Store integrated into their
interfaces.
Once you’re done selecting the hardware configurations, click next and you’ll be taken to the system
image menu.
A system image comprises the Android version, its API level and Application Binary Interface(ABI).
ABI defines with great precision, how an application's machine code is supposed to interact with the
computer.
These selections must be in accordance with your project.
Further customizations take place on the last screen for creating a new virtual device. At the bottom
of the window, you’ll find a button for the advanced settings. Here you can explore the camera
settings, network settings, performance and storage of your virtual device as per your application’s
needs.
The performance section of the settings gives you three options:
Cold boot: It will start your device as if you’re turning it on for the first time.
Quick boot: It will remember the last state of your device and the next time you run the Android
emulator it will show you the same screen.
Snapshot: This refers to the state of the Android emulator. You get to save the state yourself and it’ll
kick off from the same page the next time you run the emulator.
The memory and storage section of the settings gives you options to configure the device RAM, VM
heap, Internal storage and SD card.
ARM64 is an evolution of the original ARM architecture that supports 64-bit processing for more
powerful computing and it’s quickly becoming the standard in newer devices.
Then there’s x86, which is a bit more powerful than the ARM CPUs, but not quite as battery-friendly,
so it’s the least commonly used of the three.
Overall, ARM better embodies a mobile-first mentality, with simple instruction sets, efficiency and
low power consumption as its major priorities. The fact that it requires fewer transistors and frees up
that hardware space more than makes up for the use of RAM in a mobile device.
Used by an emulator
As a developer, through the OS images you can enjoy the built-in features of an operating
system using the application programming interface or API level. This is a whole value like API
level 30 that uniquely identifies new features that have been released for a particular OS. As the
number increases more functionalities are added.
Version Name Internal Name API Level
Android 1.0 - 1
Android 1.1 Petit Four 2
Android Cupcake Cupcake 3
Android Donut Donut 4
Android Eclair Eclair 5
Android Eclair Eclair 6
Android Eclair Eclair 7
Android Froyo Froyo 8
Android Gingerbread Gingerbread 9
Android Gingerbread Gingerbread 10
Android Honeycomb Honeycomb 11
Android Honeycomb Honeycomb 12
Android Honeycomb Honeycomb 13
Android Ice Cream Sandwich Ice Cream Sandwich 14
Android Ice Cream Sandwich Ice Cream Sandwich 15
Android Jelly Bean Jelly Bean 16
Android Jelly Bean Jelly Bean 17
Android Jelly Bean Jelly Bean 18
Android KitKat Key Lime Pie 19
Android KitKat Key Lime Pie 20
Android Lollipop Lemon Meringue Pie 21
Android Lollipop Lemon Meringue Pie 22
Android Marshmallow Macadamia Nut Cookie 23
Android Nougat New York Cheesecake 24
Android Nougat New York Cheesecake 25
Android Oreo Oatmeal Cookie 26
Android Oreo Oatmeal Cookie 27
Pie Pie 28
Android10 Android Q 29
Android11 Red Velvet Cake 30
Version Name Internal Name API Level
Android12 Snow Cone 31
Android12L Snow Cone 32
Android13 Tiramisu 33
Common libraries and packages
A fundamental lesson every developer should be aware of is “don’t reinvent the wheel.”
Understanding how to use external libraries and packages in Android Studio is a big part of that.
This is because, if you need to perform a common task, you probably don’t need to write the code
yourself. Instead, you can use libraries to help get the job done more efficiently.
The best libraries provide entirely new functionalities and give you access to awesome functions with
lesser code as a developer. Unlike copying and pasting code, libraries are entirely portable and easy
to plug in too. This makes it easy to access advanced features with minimal work or confusion.
Types of libraries
Below are the various categories in Android development and the common libraries used in them:
Image loading
Image loading libraries come in handy to avoid high memory consumption caused by loading
multiple images at the same time.
For example, Fresco is an image loading library focused on providing a smooth scrolling experience
while an image is loading. Fresco ensures image loading is as swift and smooth as possible by
applying smart caching to minimize storage overhead.
Videos
Displaying videos is usually a daunting task for developers during development. Without the use of a
library, the processes and details to take care of can be too numerous to handle.
ExoPlayer built by Google is an example of an Android media player library. It offers an alternative
to Android’s MediaPlayer API to play audio and video, locally or online, with some additional
advantages. One of ExoPlayer’s biggest benefits is its ease of customization.
Networking
Nowadays, virtually every mobile app needs some sort of network communication to perform one
function or another. Fortunately, there are incredible networking libraries available to help you
optimize this process.
For example, Retrofit is the most used networking library in Android development. It provides you
with a great way to make internet calls within your application.
Additional resources
Learn more
Here is a list of additional reading material that may consolidate some of the knowledge you've
gained so far and be helpful as you continue your learning journey.
Android OS images
Android version history
Android emulator
Configure hardware acceleration for Android emulator
path to SDK
In Android, an activity, which is one thing a user can do, is an entry point for interacting with the
user. This is where the action happens because activities allow the user to interact with your
app. An Android app is usually made of multiple activities, sometimes called screens, that
together form the user experience.
With Gradle, the Android project is managed through a set of build configuration files. These
define how a project is to be developed, what dependencies need to exist for the project to build
and run successfully and what the result or results of the compilation process should be.
For every Android project, two build.gradle files are generated. The first build.gradle settings
apply to every module in the entire project, while the second set of project-level or module-level
settings applies to only the app module.
A module is a collection of source files and build settings that allow you to divide your project
into different units of functionality. If there were another module within the project, then that
module would have its own build.gradle file.
The Android block contains information about your project, such as the minimum operating
system or OS version you want your app to use for the compilation. The default config sub block
allows you to specify the minimum OS version, version number, application unique ID and other
configuration settings. The dependencies block specifies what third-party libraries you wish to
include in your app. If a local copy is not available, all specified dependencies are automatically
downloaded for you.
Intent Filter: This is necessary in order to specify this class or this activity as the initial point of
running the application. In other words, the first page that is going to launch is the main activity
class. That's why there is an action and category tag within the intent filter. The launch a
category means that this class has been assigned as the first class that should run when your
application is running on the user device
Colours animations icons are stored in Resource folder
Resource mae wo cheezen rkhte jo aap ne kisi khas waqt show krani ho
Colors for UI Creation
For your app to support multiple device specifications, it's essential that you leverage the default
resources within the Resource folder. These resources play an important role in your apps
device compatibility. For example, if your app is going to provide multiple language support, the
resource folder helps you to define the languages. The app's language preferences are
automatically selected based on the user's default language on the device.
Also, if you want your app to be responsive across multiple devices, you can provide different
layout resources based on the screen orientation and then specify one orientation as your
default.
Project files
Choosing Project View displays many more files and directories.
build/
Contains files generated after a project build occurs
libs/
Contains private and 3rd party libraries used within the app
src/
Contains all code and resource files for the module in its subdirectories
androidTest/
Contains code for testing features of the app that runs on an emulator or a physical
device
test/
Contains code used for unit testing code, with unit tests executed on the computer
main/
Contains the Android code and resources shared by all build variants for testing and
production deployments
AndroidManifest.xml
Describes specific information about your app and each of its components such as
Activity
java/
Contains Java and Kotlin-related code files
gen/
Contains the Java files generated by Android Studio, which are required for the app to
build successfully (not displayed in the image above)
res/
Contains application resources, such as image files, layout files for user interface
designs, color files, dimension files and UI string for managing texts used across the
app
assets/
Contains files that should be compiled into an .apk file as-is (not displayed in the image
above)
You can navigate this directory in the same way as a typical file system using URIs and
read files as a stream of bytes using the AssetManager. assets/ is a good location for
video files, for example
While both the drawable and mipmap folders are used to store image assets for your app,
mipmap is an upgrade that Google introduced as an improvement to drawable. I recommend
that you use mipmap for app development.
Here is a list of additional reading material that may consolidate some of the knowledge
you've gained so far and be helpful as you continue your learning journey.
Android Activities
Introduction to Android Activities
Android Manifest
App Manifest overview
Gradle
Introduction to Gradle in Android Studio