0% found this document useful (0 votes)
5 views

Android Programming Notes UNIT-II

The document provides an overview of the Android software stack, detailing its layered architecture built on a Linux kernel, which includes libraries, an application framework, and runtime environments like Dalvik and ART. It explains the roles of various components such as the Linux kernel, Android runtime, and core libraries in managing hardware, memory, and application execution. Additionally, it highlights the differences between Dalvik and ART, emphasizing the performance improvements and features introduced with ART in Android 5.0 and beyond.

Uploaded by

vshra120626
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
5 views

Android Programming Notes UNIT-II

The document provides an overview of the Android software stack, detailing its layered architecture built on a Linux kernel, which includes libraries, an application framework, and runtime environments like Dalvik and ART. It explains the roles of various components such as the Linux kernel, Android runtime, and core libraries in managing hardware, memory, and application execution. Additionally, it highlights the differences between Dalvik and ART, emphasizing the performance improvements and features introduced with ART in Android 5.0 and beyond.

Uploaded by

vshra120626
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 17

Unit – II

(Android Architecture Overview and Application) Android Software Stack


Ans.
The Android software stack is a layered architecture built upon a Linux kernel, incorporating
C/C++ libraries, an application framework, and various system services, ultimately enabling
the execution of applications on Android devices. In order to understand how Android works,
take a look at Figure , which shows the various layers that make up the Android operating
system (OS). The Android OS is roughly divided into five sections in four main layers:
1. Linux kernel — This is the kernel on which Android is based. This layer contains all the
low level device drivers for the various hardware components of an Android device.
2. Libraries — These contain all the code that provides the main features of an Android OS.
For example, the SQLite library provides database support so that an application can use it for
data storage. The WebKit library provides functionalities for web browsing.
Surface Manager - manages access to the display subsystem and seamlessly composites 2D
and 3D graphic layers from multiple applications.
Android multimedia framework is designed to provide a reliable interface for java service. It
is a system that includes multimedia applications, frameworks, an OpenCore engine, hardware
devices for audio/video/ input, output devices also several core dynamic libraries such as
libmedia, libmedia playservices, and so on.
OpenGL ES (OpenGL for Embedded Systems) is a graphics API used on Android devices,
allowing developers to render high-quality 2D and 3D graphics on mobile devices by leveraging
the power of the device's GPU, essentially providing a way to create visually rich applications
like games and animations within the Android platform.
FreeType is a software development library used to render text onto bitmaps, and which
provides support for other font-related operations. The FreeType font rasterization engine is free
and open-source software with the source code dual-licensed under a BSD-like license and the
GPL
WebKit refers to an open-source web browser engine used to render web pages within
applications, primarily through the "WebView" component; essentially, it's the underlying
technology that allows Android apps to display web content within their interface, similar to
how Apple's Safari browser utilizes WebKit on iOS devices.
SGL stands for "Scalable Graphics Library," which is a 2D graphics library used alongside OpenGL (for
3D graphics) to render graphics within the Android system; essentially, it provides a way to draw 2D
images on the screen within Android applications.
SSL stands for "Secure Sockets Layer," which is a security protocol used to encrypt data
transmitted between an Android app and a server, ensuring that sensitive information like login
credentials or personal details remain private and protected from eavesdropping during
communication over the internet; essentially, it's a way to establish a secure connection between
your app and a website or server by encrypting the data being sent and received.
Libc is part of Native C/C++ Libraries which provide an important functions that could be used by the
application to interact with the operating system.
(Ref: https://google.com )
3. Android runtime — At the same layer as the libraries, the Android run-time provides a set
of core libraries that enable developers to write Android apps using the Java programming
language. The Android run-time also includes the Dalvik virtual machine, which enables
every Android application to run in its own process, with its own instance of the Dalvik
virtual machine (Android applications are compiled into Dalvik executable).
4. Application framework — Exposes the various capabilities of the Android OS to
application developers so that they can make use of them in their applications.
5. Applications — At this top layer, you will find applications that ship with the Android
device (such as Phone, Contacts, Browser, etc.), as well as applications that you download
and install from the Android Market. Any applications that you write are located at this layer.

Figure 1: Android System Architecture

(Ref: University of Babylon - College of IT – SW Dep. - Android Assist. Lect. Wadhah R. Baiee 2014)
( https://www.google.com )

The Linux Kernel(Android)


Ans.

The Linux kernel is the


most significant
component of a Linux
operating system, since it
serves as the primary interface between a computer's hardware and its functions (OS). It
connects the two, allowing for the most efficient use of resources. Like a seed inside a hard
shell, it resides within the OS and conducts all the hardware's critical tasks, whether it's a
phone, laptop, server, or any other sort of computer. The kernel is responsible for low-level
operations such as disk management, memory management, task management, and so on. It
connects the user to the hardware components of the system. When a process requests
anything from the kernel, this is called a System Call.
A kernel exists in some form in all multitasking operating systems. Windows has a kernel, as
does OS X, iOS has a kernel, and Android, of course, has a kernel. Only Android, however,
uses the Linux kernel.
A kernel may access a variety of computer resources such as the CPU, I/O devices, and
other resources. It serves as a link between the user and the system's resources.
Resource Management: It is the responsibility of a kernel to share resources across multiple
processes in such a way that each process has uniform access to the resources.
Memory Management: Every process necessitates a certain amount of memory. As a result,
memory must be allocated and released for it to run. A kernel is in charge of memory
management.
Device Management: The procedures take advantage of the peripheral devices linked to the
system. As a result, the kernel oversees device allocation.
Network Stack: It effectively handles the network communication.
Driver Model:The main purpose of device drivers is to provide abstraction by acting as a
translator between a hardware device and the operating system, helping in running atached
hardware ( display, WI-FI and audio).
Security: The Linux kernel handles the security between the application and the system.

The Android operating system is based on the Linux kernel, with certain architectural tweaks
by Google. The Linux kernel was chosen for a variety of reasons. Most notably, Linux is a
portable operating system that can be quickly built on a variety of hardware.
The kernel serves as a layer of abstraction between the device's software and hardware.
Consider the scenario of a camera shutter release. What occurs when you use your device's
camera button to snap a photo? The hardware instruction (pressing a button) must be
transformed to a software instruction at some point (to take a picture and store it in the
gallery).

Drivers are included in the kernel to help with this procedure. When a user pushes a button,
the instruction is sent to the kernel's related camera driver, which delivers the required
commands to the camera hardware, just as when a key is pushed on a keyboard. The drivers
in the kernel command, in basic terms, control the underlying hardware. Android's basic
functionality, including process management, memory management, security, and
networking, is managed by the Linux kernel. When it comes to security and process
management, Linux is a tried-and-true platform.

Android has built a solid basis for its ecosystem by leveraging the existing Linux open-source
OS. The underlying Linux kernel is different for each version of Android.
The kernel is the most important component of every operating system. It oversees the
computer's and hardware's functions, particularly memory and CPU time. Android was
created with a strong emphasis on security. Android as a platform provides and enforces
various measures that employ multi-layered security to protect user data on mobile devices.
The Linux kernel sits behind the Android-specific modules and frameworks. The Linux
kernel comprises code for all the numerous chip architectures and device drivers it supports,
in addition to controlling processes, memory, and power management. Cameras, Bluetooth,
Wi-Fi, flash memory, USB, and audio drivers are among them. To make the Linux kernel
more suited for smartphones, Android adds several additional capabilities to it. Low Memory
Killer, a process that checks memory status and reacts to high memory demands by killing the
least critical programs while keeping the system functioning, and wake locks, a means for
apps to inform the kernel that the device needs to stay on, are two examples.
(Ref: https://emteria.com/learn/linux-kernel )

Android Runtime - Dalvik Virtual Machine.


Ans.
Dalvik Virtual Machine (DVM) is a Java virtual
machine developed and written by Dan
Bornstein and others as part of the Android
mobile platform.
We can say that Dalvik is a runtime for Android
operating system components and user
applications. Each process is executed in its
isolated domain. When a user starts an app (or
the operating system launches one of its
components), the Dalvik virtual machine kernel
(Zygote Dalvik VM) creates a separate, secure
process in shared memory, where VM is
directly deployed as the Android runtime
environment. In short, Android within looks like a set of Dalvik virtual machines, with
executing an app in each.
DVM features:
Register-based architecture. The data structure with methods placed there is based on
processor registers. Due to POP and PUSH absence, instructions in register VM are executed
faster than similar ones in stack VM
Executes the bytecode of its format. Android dexer converts .class files into .dex format
optimized for DVM execution. Unlike a .class file, a .dex file contains several classes at once.

Android Dexer :A crucial step in


creating an APK is converting the Java
bytecode to .dex bytecode for Android
Runtime and Android developers to
know about it. The dex compiler
mainly works “undercover” in routine
application development, but it directly
affects the application build time, .dex
file size, and runtime performance. As already mentioned, the .dex file itself contains several
classes at once. Repeating strings and other constants, used in multiple .class files, are
included only to save space. Java bytecode is also converted to an alternative command set
used by DVM. An uncompressed .dex file is usually a few percent smaller than a compressed
Java archive (JAR) from the same .class files. Initially, .class files were converted to .dex
using the built-in DX compiler. But starting from Android Studio 3.1 onwards, the default
compiler was D8. Compared to the DX compiler, the D8 compiles faster and outputs
smaller .dex files, providing high application performance during runtime. The resulting
bytecode is minified using an open-source utility ProGuard. As a result, we get the same .dex
file, but smaller. Then this file is used for APK building and finally for deploying it on the
Android device.
(Ref: https://intexsoft.com/blog/android-runtime-environment-dvm-vs-art/ )

Android Runtime – Core Libraries


Ans.
The Android runtime (ART) is the default runtime for devices running Android 5.0 (API level
21) and higher. This runtime offers a number of features that improve performance and
smoothness of the Android platform and apps.ART as the runtime executes the Dalvik
executable (DEX) format and DEX bytecode specification.
ART introduces ahead-of-time (AOT) compilation, which can improve app performance.
ART also has tighter install-time verification than Dalvik.
At install time, ART compiles apps using the on-device dex2oat tool. This utility accepts
DEX files as input and generates a compiled app executable for the target device. The utility
should be able to compile all valid DEX files without difficulty. However, some post-
processing tools produce invalid files that may be tolerated by Dalvik but cannot be compiled
by ART.

ART and Dalvik are compatible runtimes running DEX bytecode, so apps developed for
Dalvik should work when running with ART.
Android Runtime Core Libraries Mainly consists of 3 parts:
▪ JAVA Libraries
▪ Android Libraries
▪ DVM Libraries
Standard JAVA libraries is a must alongside specific libraries for Android to control and
access media, databases etc. DVM Libraries are specifically used to interact with the Dalvik
Virtual Machine

Difference between ART and DVM


DVM was explicitly designed for mobile devices and
was used as a virtual machine to run android apps up
until Android 4.4 Kitkat.
Starting from this version, ART was introduced as a
runtime environment, and in Android 5.0 (Lollipop),
ART completely replaced Dalvik.
The main visible difference between ART and DVM is
that ART uses AOT(Ahead-of-Time:involves compiling app
bytecode into native machine code during the installation
phase, resulting in faster and more energy-efficient app
execution) compilation, while DVM – JIT(Just-In-Time: improves app performance by
dynamically compiling code during runtime, complementing the existing Ahead-of-Time
(AOT) compilation) compilation. Not so long ago, ART started using a hybrid of AOT and
JIT. We’ll take a look at this a little bit further.

DMV
• Uses JIT Compilation: whenever you start an application, the part of the code
necessary for app execution compiles. The rest of the code compiles dynamically. This
slows down app launch and operation but reduces the installation time.
• Speeds up the device’s startup because the application cache is created at runtime.
• DVM apps require less memory than those running on ART.
• Reduces battery performance by increasing the CPU load.
• Dalvik is “obsolete” and is not used on Android versions above 4.4.
ART
• Uses AOT compilation, i.e., compiles all code during the installation of the app. This
speeds up apps running and operation but requires more installation time.
• Slows the device’s startup because the cache is created during the first boot.
• Due to the AOT compilation approach, requires more memory compared to DVM
applications.
• Increases battery performance by reducing CPU operation due to the compilation
absence when running applications.
• Improved Garbage Collection. When using Dalvik, garbage collectors had to perform
two heap passes, which resulted in bad UX(User Experience). In the case of ART, this is
not the case: it cleans the heap once for memory consolidation.

(Ref : https://intexsoft.com/blog/android-runtime-environment-dvm-vs-art/
https://developer.android.com/guide/practices/verifying-apps-art.html )

Dalvik VM Specific Libraries


Ans.

The Dalvik Virtual Machine (DVM) is a custom virtual machine designed for running
Android applications, executing Dalvik bytecode (compiled from Java code) and optimized
for low-memory, mobile devices, and it was replaced by Android Runtime (ART) in Android
5.0 . The native code in the core libraries (chiefly dalvik/libcore, but also dalvik/vm/native)
is written in C/C++ and is expected to work without modification in a Linux environment.
Much of the code comes directly from the Apache Harmony project.The core libraries pull in
code from many other projects, including OpenSSL, zlib, and ICU. These will also need to be
ported before the VM can be used.
Core Libraries:
The Dalvik core libraries are written in C/C++ and are designed to work in a Linux
environment.
• dalvik/libcore
It is a library of core Java classes and utilities used by the Android platform . A
collection of core Java libraries and utilities that are part of the Android platform.
◦ These libraries provide fundamental functionality, such as networking, I/O, and
security, that is used by Android applications and the system itself.
◦ libcore is written in Java and is designed to be platform-independent, meaning it
can run on different hardware and operating systems.
◦ The native code in the core libraries (chiefly dalvik/libcore) is written in C/C++
and is expected to work without modification in a Linux environment.
◦ libcore is part of the Android Open Source Project (AOSP)
• dalvik/vm/native
"native" refers to code written in languages like C/C++ and executed directly by
the device's CPU.
◦ "Native" refers to code written in languages like C or C++, which are compiled
directly into machine code for the specific hardware architecture.
◦ Android applications can use native code for performance-critical tasks or to access
hardware features that aren't easily available through Java.
◦ The Java Native Interface (JNI) allows Java code to interact with native code.
External Libraries:
The core libraries also pull in code from other projects, including:
• OpenSSL
• zlib
• ICU ( International Components for Unicode )
(Ref : www.google.com)

Java Interoperability Libraries


Ans.
Java interoperability means that a code written in one can be easily executed in another with
some changes. Java interoperability refers to the ability of Java applications to interact and
work seamlessly with code written in other programming languages, such as C, C++, or even
scripting languages like Python and JavaScript. This interoperability is achieved through
various mechanisms, including the Java Native Interface (JNI), which allows Java code to
call and be called by native applications and libraries, and through the Java Virtual Machine
(JVM), which can execute code compiled from other languages that target the JVM, like
Kotlin or Scala. Furthermore, Java can communicate with web services, APIs, and databases,
making it a versatile choice for building applications that need to integrate diverse
technologies, thereby enhancing its utility in heterogeneous environments.

These are tools and frameworks that allow Java applications to interact with code or systems
written in other languages or technologies. Java Interoperability Libraries facilitate
communication and interaction between Java code and other languages or systems, enabling
the use of existing libraries and frameworks in a Java environment or vice versa. They enable
Java to leverage existing libraries and frameworks, enhance system integration, and take
advantage of specific language or platform advantages.
Benefits:

• Reuse of Existing Code: Leverage pre-existing libraries and frameworks written in


other languages.
• Enhanced System Integration: Integrate Java applications with other systems and
components.
• Performance Optimization: Utilize specialized libraries for specific tasks (e.g., native
code for performance-critical sections).
• Leveraging Language Advantages: Take advantage of the strengths of different
languages.

Examples
• Java Native Interface (JNI): Allows Java code to call native methods (written in
languages like C or C++) and vice versa.
• GraalVM: Enables JavaScript code to access Java libraries and services directly.
• Kotlin: Kotlin, a JVM language, is designed with Java interoperability in mind,
allowing seamless integration of Kotlin and Java code.
• Other Interoperability Efforts: Libraries like Swift-Java are being developed to
facilitate interoperability between Java and Swift.

(Ref : https://justacademy.co/blog-detail/java-interoperability )

Android Libraries
Ans.
The Android Library provides the
device with a set of instructions
that allow it to handle different
types of data in an appropriate way.
As part of Android development,
native libraries are required, and
most of these libraries are open-
source. It is a collection of C/C++
core libraries as well as Java-based
libraries, which support Android development, such as Graphics, Libc, SSL (Secure Socket
Layer), SQLite, Media, Webkit, OpenGL (Open Graphic Library), Surface Manager, etc. Here
are some details about some key Android libraries that are available for Android
development..
Surface Manager - manages access to the display subsystem and seamlessly composites 2D
and 3D graphic layers from multiple applications.
Android multimedia framework is designed to provide a reliable interface for java service. It
is a system that includes multimedia applications, frameworks, an OpenCore engine, hardware
devices for audio/video/ input, output devices also several core dynamic libraries such as
libmedia, libmedia playservices, and so on.
OpenGL ES (OpenGL for Embedded Systems) is a graphics API used on Android devices,
allowing developers to render high-quality 2D and 3D graphics on mobile devices by leveraging
the power of the device's GPU, essentially providing a way to create visually rich applications
like games and animations within the Android platform.
FreeType is a software development library used to render text onto bitmaps, and which
provides support for other font-related operations. The FreeType font rasterization engine is free
and open-source software with the source code dual-licensed under a BSD-like license and the
GPL
WebKit refers to an open-source web browser engine used to render web pages within
applications, primarily through the "WebView" component; essentially, it's the underlying
technology that allows Android apps to display web content within their interface, similar to
how Apple's Safari browser utilizes WebKit on iOS devices.
SGL stands for "Scalable Graphics Library," which is a 2D graphics library used alongside OpenGL (for
3D graphics) to render graphics within the Android system; essentially, it provides a way to draw 2D
images on the screen within Android applications.
SSL stands for "Secure Sockets Layer," which is a security protocol used to encrypt data
transmitted between an Android app and a server, ensuring that sensitive information like login
credentials or personal details remain private and protected from eavesdropping during
communication over the internet; essentially, it's a way to establish a secure connection between
your app and a website or server by encrypting the data being sent and received.
Libc is part of Native C/C++ Libraries which provide an important functions that could be used by the
application to interact with the operating system.
(Ref: https://www.interviewbit.com/blog/android-architecture/)
Application Framework
Ans.
The application framework that
stands on top of the native libraries
and runtime layer provides us with
Application Programming
Interfaces (APIs) and higher-level
services. The Android Application
Framework provides classes, interfaces, and utilities that are used for the development of
Android applications. Also included in this framework is an Android Hardware Abstraction
Layer (HAL), which allows the application to communicate with hardware-specific device
drivers and to manage both the UI and resources. The overall aim of it is to provide services
through which we can create a particular class and make that particular class available for aid
when creating applications. The Android framework includes the following high-level
services that can be beneficial for developing mobile applications according to our
prerequisites:

• Activity Manager: Plays a crucial role in bringing all aspects of the applications
lifecycle and activity stack under control.
• Content Providers: These providers enable applications to publish data online and
share it with other applications.
• Resource Manager: Assists in accessing non-code embedded resources such as strings,
color settings, and layouts for user interfaces.
• Notifications Manager: Allows applications to show alerts and notifications to users
via the user interface of the application.
• View System: It serves as a base class for widgets and handles events.

(Ref: https://www.interviewbit.com/blog/android-architecture/)
Creating a New Android Project
Ans.
Creating the Project:
Open Eclipse: Launch the Eclipse IDE.
File > New > Project: Navigate to the "File" menu
and select "New" > "Project".
Select Android Project: In the "New Project"
dialog, expand the "Android" folder and select
"Android Project".
Next: Click "Next" to proceed to the project
creation wizard.
Project Details:
Project Name: Enter the name for
your Android project.
Location: Choose the directory
where you want to store the project.
Build Target: Select the target
Android SDK version for your project.
Application Name: Enter the name
of your application.
Package Name: Enter the package
name for your application.
Create Activity: Choose to create a
new activity or leave it unchecked.
Next: Click "Next" to proceed to the next
step.
Activity Template (Optional): If you
chose to create an activity, select an
activity template (e.g., Blank Activity).
Finish: Click "Finish" to create the Android project.
(Ref : https://www.google.com/ )

Defining the Project Name and SDK Settings


Ans.

In the Eclipse SDK, the project name is a crucial identifier used to organize and manage
software development projects within the Eclipse IDE, serving as the basis for project
organization, file structure, and build configurations.
Project Organization:
The project name is used to create a dedicated directory structure within the Eclipse
workspace, which holds all the project's files, source code, and build artifacts.
Build Configuration:
The project name is used to identify the project when configuring build processes, such as
compiling, packaging, and deploying applications.
Dependency Management:
Project names are used to establish dependencies between different projects within a
workspace, allowing for modular development and reuse of code.
Eclipse SDK Naming Conventions:
When developing plug-ins for the Eclipse project itself, the name of the Eclipse workspace
project should match the name of the plug-in.
Project Description File:
The project name is stored in the .project file, which is a crucial part of the Eclipse workspace
API, ensuring that projects can be recreated and managed correctly in different workspaces.
Source Code Management:
The project name is often used in conjunction with source control systems (like Git) to
manage the project's code base and track changes.

SDK settings, particularly for platforms like Android, are crucial because they tell the IDE
where to find the necessary tools, libraries, and APIs for building and running applications
targeting those platforms. Without proper SDK configuration, Eclipse won't be able to
compile, debug, or deploy your code.
Here's a more detailed breakdown:

What SDK Settings Are:


SDK (Software Development Kit) settings in Eclipse specify the location of the SDK
directory, which contains the tools, libraries, and APIs needed for developing applications for
a specific platform (e.g., Android, Java).

Why They Matter:

Compilation: Eclipse uses the SDK tools to compile your code into a runnable format.
Debugging: The SDK provides debugging tools that allow you to step through your code and
identify issues.
Deployment: The SDK contains the necessary tools for deploying your application to a target
device or emulator.
API Access: SDK settings ensure that Eclipse can access the necessary APIs for the platform
you're developing for.

How to Configure SDK Settings:

Android SDK:
Install the Android Development Tools (ADT) plugin in Eclipse.

Navigate to Window > Preferences > Android and specify the location of your Android SDK
directory. Use the Android SDK Manager to download and install the necessary SDK
platforms and tools.

( Ref: https://www.google.com/)
Project Configuration Settings
Ans.
To configure your Android project in Eclipse, right-click the project in the Project Explorer,
select "Properties", and then navigate to the specific settings you want to modify, like
"Android"
Access Project Properties:
• In the Eclipse Project Explorer, locate the Android project you want to configure.
• Right-click on the project name.
• Select "Properties" from the context menu.
Modify Settings:
Once you've navigated to the desired settings, you can modify the values as needed.
For example, you might change the target SDK version, add a new library, or modify the
project's source folder.
Click "OK" or "Apply" to save the changes.

Examples of common settings to configure:

Android SDK: Ensure you have the correct Android SDK installed and selected for your
project.
Target SDK: Choose the Android API level your application is designed for.
Minimum SDK: Set the lowest Android API level your application will support.
Application Package Name: Specify the unique identifier for your application.
Dependencies: Add or remove libraries your project needs to function.
Build Path: Configure where your source code and resources are located.
Build Configuration: Set up different build configurations for different scenarios, like debug
and release builds.

( Ref: https://www.google.com/)

Configuring the Launcher Icon


Ans.
Launcher icons are used by Launcher applications and appear on the
user's Home screen. Launcher icons can also be used to represent
shortcuts into your application (for example, a contact shortcut icon
that opens detail information for a contact).
Goals of the Launcher Icon
Application launcher icons have three primary goals:

• Promote the brand and tell the story of the app.


• Help users discover the app on Google Play.
• Function well in the Launcher.
Promote the brand story - App launcher icons are an opportunity to showcase the brand and
hint at the story of what your app is about. Thus, you should:
• Create an icon that is unique and memorable.
• Use a color scheme that suits your brand.
• Don't try to communicate too much with the icon. A simple icon will have more impact
and be more memorable.
• Avoid including the application name in the icon. The app name will always be
displayed adjacent to the icon.
Help users discover the app on Google Play
App launcher icons are the first look that prospective users will get of your app on Google Play.
A high quality app icon can influence users to find out more as they scroll through lists of
applications.
Quality matters here. A well-designed icon can be a strong signal that your app is of similarly
high quality. Consider working with an icon designer to develop the app’s launcher icon.

Function well in the Launcher - The launcher is where users will interact with the icon most
frequently. A successful app launcher icon will look great in all situations: on any background
and next to any other icons and app widgets. To do this, icons should:

• Communicate well at small sizes.


• Work on a wide variety of backgrounds.
• Reflect the implied lighting model of the launcher (top-lit).
• If the icon is 3D, use a perspective that doesn't feel out of place with other icons;
forward-facing works best.
• 3D icons work best with a shallow depth.
• Have a unique silhouette for faster recognition; not all Android app icons should be
square.
• Icons should not present a cropped view of a larger image.
• Have similar weight to other icons. Icons that are too spindly or that don't use enough
of the space may not successfully attract the user’s attention, or may not stand out
well on all backgrounds.

(Ref:https://devdoc.net/android/Android-r15/guide/practices/ui_guidelines/icon_design_launcher.html)

Creating an Activity
Ans.
an Activity is a fundamental building block that
represents a single screen or a user interface with
which the user interacts. It serves as the entry point
for an app's interaction with the user, managing the
UI(User Interface) and user interactions.

Types of Activities:

Basic Activity: A standard activity that serves as the


foundation for most Android applications.
Fullscreen Activity: n activity that displays content
in full-screen mode, hiding the system UI.
Login Activity: An activity designed for user authentication, allowing users to log in or
register.
Navigation Drawer Activity: An activity that incorporates a navigation drawer, a sliding menu
for navigation links.
Tabbed Activity: An activity that uses tabs for organizing and displaying different sections of
content.

Activity Lifecycle:

onCreate(): Called when the activity is first created, responsible for initializing the UI and
setting up the layout.
onStart(): Called when the activity becomes visible to the user.
onResume(): Called when the activity is about to start interacting with the user, capturing user
input.
onPause(): Called when the activity is losing focus, typically when another activity is starting
or the user navigates away.
onStop(): Called when the activity is no longer visible to the user and is in the background.
onDestroy(): Called when the activity is being destroyed, typically when the user navigates
away and the activity is no longer needed.
onRestart(): Called when the activity is being restarted after being stopped.
onSaveInstanceState(): Called before the activity is destroyed to save any state that needs to
be restored later.
onRestoreInstanceState(): Called after the activity is recreated to restore the saved state.

Activity States:
Running: The activity is at the top of the activity stack and is interacting with the user.
Paused: The activity is partially hidden and does not receive user input.
Stopped: The activity is completely hidden and is not visible to the user.
Destroyed: The activity is no longer running and has been removed from the activity stack.

Role of an Activity:

User Interface Representation:


An Activity is essentially a single screen or window within your Android application. It's
where the user interface (UI) elements, like buttons, text fields, and images, are displayed and
where user interactions occur.

Entry Point for Interaction:


Activities are the primary way users interact with your app. They are the starting point for an
app's functionality, and the system manages their lifecycle (creation, running, pausing,
stopping, and destruction).

Lifecycle Management:
Activities go through a lifecycle, with various callback methods (like onCreate(),
onResume(), onPause(), etc.) that are triggered at different points in the activity's existence.
These callbacks allow you to control how your activity behaves when it's created, becomes
visible, goes into the background, or is destroyed.

Managed in a Stack:
Android manages Activities in a stack, meaning when you start a new Activity, it's placed on
top of the existing one. The user can navigate back through the stack using the back button,
returning to the previous Activities.

Using Intents:
Activities can communicate with each other (and other Android components) using Intents,
which are essentially messages that specify an action to be performed. For example, you can
use an Intent to start a new Activity, send data between Activities, or trigger an action in
another app.
Layout Files:
Activities typically use XML layout files to define their UI, allowing for a separation of
concerns between the UI and the code that handles user interactions.
Manifest Declaration:
Every Activity must be declared in the AndroidManifest.xml file, which tells the Android
system which Activities are part of your application

(Ref: https://www.google.com/ )

Running the Application in the AVD


Ans.
To run your Android application in an AVD (Android Virtual Device) within Eclipse, first
ensure you have the ADT (Android Development Tools) plugin installed and an AVD
configured. Then, select your desired AVD from the toolbar, and click the "Run" button.

Prerequisites:
• Android SDK and ADT Plugin: Make sure you have the Android SDK installed and
the ADT plugin configured within Eclipse.
• AVD Configuration:Create an AVD using the Android Virtual Device Manager
(Window > AVD Manager).
• Project Setup:Ensure your Android project is properly set up with the necessary SDK
and build targets.
Running the Application:
• Select AVD: In the Eclipse toolbar, locate the dropdown menu that allows you to select
the target device (AVD or physical device).
• Choose AVD: Select the AVD you want to use from the dropdown menu.
• Run Application: Click the "Run" button (or select Run > Run from the menu).
• Emulator Launch: Eclipse will compile your project, install the application on the
selected AVD, and launch the emulator.
• Troubleshooting: If you encounter issues, consult the Android documentation for
troubleshooting tips.
(Ref: https://www.google.com/ )
Stopping a Running Application
Ans.
To stop an application running in an AVD (Android Virtual Device) within Android Eclipse,
you can either click the "Stop" button in the Debug perspective or use the "Terminate" option
in the Debug view.
(Ref: https://www.google.com/ )

Modifying the Example Application


Ans.
To modify an Android application within Eclipse, you'll primarily work with the Android
Development Tools (ADT) plugin, making changes to the project's code, layout files, and the
AndroidManifest.xml file.

Understanding the Project Structure:


AndroidManifest.xml: his file contains crucial information about your application, including
its name, package, permissions, activities, and more.
res folder: This folder holds your application's resources, such as layouts, images, strings, and
more.
src folder:This folder contains your Java code, including activities, services, and other
classes.
build.gradle (or project.properties):These files contain build configurations and dependencies.

Modifying the Application:


Code Changes: Open the Java files in the src folder and modify the code to implement new
functionality or change existing behavior.
Use Eclipse's code editor features for syntax highlighting, auto-completion, and debugging.
Layout Changes:Open the XML files in the res/layout folder to modify the user interface.
Use the Eclipse's layout editor for a visual interface.
Resource Changes:Modify images, strings, and other resources in the res folder.
Manifest Changes:Open the AndroidManifest.xml file to make changes to the application's
metadata, permissions, and activities.
Build Configuration:Modify the build.gradle (or project.properties) file to change build
settings, dependencies, and signing configurations.

Running and Debugging:


Connect Device: Connect your Android device to your computer and enable USB debugging.
Run Application: Right-click on the project in the Project Explorer and select "Run As" >
"Android Application".
Debug Application: Use Eclipse's debugging tools to step through your code and identify
issues.
Exporting the Application:
Create APK: Right-click on the project in the Project Explorer and select "Android Tools" >
"Export Signed Application Package" or "Export Unsigned Application Package".
(Ref: https://www.google.com/ )

Reviewing the Layout and Resource Files


Ans.

To review and edit layouts in Android Eclipse, navigate to the res/layout directory in the
Package Explorer, double-click a layout file, and then use the "Design" or "Source" tabs to
view and modify the UI visually or through XML code, respectively.
Accessing the Layout Files:
Navigate to the res/layout directory: In the Eclipse Package Explorer, locate your Android
project and navigate to the res folder, then the layout sub-folder.
Open a Layout File: Double-click on the XML file representing the layout you want to review
(e.g., activity_main.xml).
Viewing and Editing the Layout:
Design Tab: The "Design" tab provides a visual representation of the layout, allowing you to
drag and drop UI elements and adjust their positions and sizes.
You can preview the layout on different screen sizes and orientations within the design view.

To review resource files in Android Eclipse, navigate to the "res" folder within your project's
Package Explorer and double-click any resource file to open it in an Android-specific view,
rather than raw code.
Locate the Resource Files: In Eclipse's Package Explorer, your project structure should show
a folder named "res" (for resources).
Open Resource Files: Double-click on any resource file within the "res" folder to open it in an
Android-specific view.
Accessing Resources in Code:
You can access resources in your Java code using the R class, which is automatically
generated by Eclipse. For example, to access a string resource named "hello", you would use
R.string.hello.
Accessing Resources in XML:
In XML layouts, you can reference resources using the @ symbol followed by the resource
type and resource name (e.g., @string/hello).

( https://www.google.com )

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy