Name: Omar Magdy Abd El Zaher Mohamed Refaei ID: 32016272 Course Name: Android App Development 3hands
Name: Omar Magdy Abd El Zaher Mohamed Refaei ID: 32016272 Course Name: Android App Development 3hands
ID : 32016272
Course Name: Android App Development
3Hands
2 Android app development
Course Content :-
abreviations
Introduction to Android
Android history
Chapter 1 :- Basics
Data types and control flow statements
Control flow statements
If else statements
For loop
Setup Encviroment
Android virtual Device
Hello world app
Android Life cycle
Activities in android
Activities and intents
Chpater 2 :- services and broadcast receivers
Location manager
Broadcast receiver
Chpater 3 :- Resources folder
Strings
Styles
Colors
Chapter 4:- Practical examples
A simple greetings application
Changing background color app
Conclusions
References
Abbreviations
Omar Magdy
2
3 Android app development
Omar Magdy
3
4 Android app development
Introduction to Android
Android is a mobile operating system developed by Google based on a modified
version of the Linux kemel and other open source software and designed primarily
for touchscreen mobile devices such as smartphones and tablets In addition, Google has
further developed android TV for televisions, Android Auto for cars, and Wear Os for wrist
watches, each with a specialized user interface. Variants of Android are also used on game ,
consoles , digital cameras , PC’s and other electronics.
Initially developed by Android Inc., which Google bought in 2005, Android was unveiled in
2007, with the first Commercial Android Device launched in September 2008. The operating
system has since gone through multiple major releases, with the current version being 8.1
“Oreo”, released in December 2017.
Omar Magdy
4
5 Android app development
Android History
Alpha
There were at least two internal releases of the software inside
Google and the OHA before the beta version was released.
To avoid confusion, the code names "Astro Boy" and "Bender" were
only known to be tagged internally on some early pre-1.0 milestone
builds, and thus were never used as the actual code names of
the 1.0 and 1.1 release of the OS, as many people are mistakenly
calling and repeating on the web. Dan Morrill created some of the first
mascot logos, but the current Android logo was designed by Irina
Blok. The project manager, Ryan Gibson, conceived the
confectionery-themed naming scheme that has been used for the
majority of the public releases, starting with Android 1.5 Cupcake.
Beta
The beta was released on November 5, 2007, while the software
development kit (SDK) was released on November 12, 2007. The
November 5 date is popularly celebrated as Android's
"birthday". Public beta versions of the SDK were released in the
following order:
Omar Magdy
5
6 Android app development
Creation :-
Android Inc. was founded in palo alto, California in October 2003 by Andy Rubin, Rich
Miner, Nick Sears, and Chris White. Rubin described the Android project as "tremendous
potential in developing smarter mobile devices that are more aware of its owner's location
and preferences". The early intentions of the company were to develop an advanced
operating system for digital cameras, and this was the basis of its pitch to investors in April
2004.[16] The company then decided that the market for cameras was not large enough for its
goals, and by five months later it had diverted its efforts and was pitching Android as a
handset operating system that would rival Symbian and Microsoft Windows Mobile.
Rubin had difficulty attracting investors early on, and Android was facing eviction from its
office space. Steve Perlman, a close friend of Rubin, brought him $10,000 in cash in an
envelope, and shortly thereafter wired an undisclosed amount as seed funding. Perlman
refused a stake in the company, and has stated "I did it because I believed in the thing, and I
wanted to help Andy."
In July 2005, Google acquired Android Inc. for at least $50 million. Its key employees,
including Rubin, Miner and White, joined Google as part of the acquisition. Not much was
known about the secretive Android at the time, with the company having provided few details
other than that it was making software for mobile phones. At Google, the team led by Rubin
developed a mobile device platform powered by the Linux Kemel. Google marketed the
platform to handset makers and carriers on the promise of providing a flexible, upgradeable
system.[21] Google had "lined up a series of hardware components and software partners and
signaled to carriers that it was open to various degrees of cooperation"
Speculation about Google's intention to enter the mobile communications market continued
to build through December 2006. An early prototype had a close resemblance to
a BlachBerry phone, with no touchscreen and a physical Qwerty Keyboard, but the arrival of
2007's Apple Iphone meant that Android "had to go back to the drawing board". Google later
changed its Android specification documents to state that "Touchscreens will be supported",
although "the Product was designed with the presence of discrete physical buttons as an
assumption, therefore a touchscreen cannot completely replace physical buttons". By 2008,
both Nokia and BlackBerry announced touch-based smartphones to rival the Iphone 3G, and
Android's focus eventually switched to just touchscreens. The first commercially available
Omar Magdy
6
7 Android app development
smartphone running Android was the HTC dream, also known as T-Mobile G1, announced
on September 23, 2008.
HTC Dream or T-Mobile G1, the first commercially released device running Android (2008).
Eric Schmidt, Andy Rubin and Hugo Barra at a 2012 press conference announcing Google's Nexus 7
tablet
From 2008 to 2013, Hugo Barra served as product spokesperson, representing Android at
press conferences and Google I/O, Google’s annual developer-focused conference. He left
Google in August 2013 to join Chinese phone maker Xiaomi.[41][42] Less than six months
earlier, Google's then-CEO Larry Page announced in a blog post that Andy Rubin had moved
Omar Magdy
7
8 Android app development
from the Android division to take on new projects at Google, and that Sundar Pichai would
become the new Android lead.[43][44] Pichai himself would eventually switch positions,
becoming the new CEO of Google in August 2015 following the company's restructure into
the Alphabet conglomerate, making Hiroshi Lockheimer the new head of Android.
In June 2014, Google announced Android One, a set of "hardware reference models" that
would "allow [device makers] to easily create high-quality phones at low costs", designed for
consumers in developing countries. In September, Google announced the first set of Android
One phones for release in India. However, Recode reported in June 2015 that the project
was "a disappointment", citing "reluctant consumers and manufacturing partners" and
"misfires from the search company that has never quite cracked hardware". Plans to
relaunch Android One surfaced in August 2015, with Africa announced as the next location
for the program a week later. A report from The Information in January 2017 stated that
Google is expanding its low-cost Android One program into the United States, although The
Verge notes that the company will presumably not produce the actual devices itself.
Google introduced the Pixel and pixel xl smartphones in October 2016, marketed as being
the first phones made by Google, and exclusively featured certain software features, such as
the Google Assistant, before wider rollout. The Pixel phones replaced the Nexus series,
[64]
with a new generation of Pixel phones launched in October 2017.
Omar Magdy
8
9 Android app development
Integer
Control flow statements are what controls the movement or the sequence of actions
performed by the code. The most popular control flow statements are:
If-else statements
Omar Magdy
9
10 Android app development
For loop:
Is similar to the if statement but more efficient when stating multiple conditions.
For (variable,condition,operation)
E.g. For (i=0,i>2,i++)
Setup Enviroment :-
In the Welcome to Android Studio window, click Start a new Android Studio
project.
Omar Magdy
10
11 Android app development
First, be sure the Project window is open (select View > Tool Windows >
Project) and the Android view is selected from the drop-down list at the top of
that window. You can then see the following files:
This is the main activity (the entry point for your app). When you build and run
the app, the system launches an instance of this Activity and loads its layout.
This XML file defines the layout for the activity's UI. It contains a textview element
with the text "Hello world!".
The manifest file describes the fundamental characteristics of the app and
defines each of its components.
Omar Magdy
11
12 Android app development
You'll see two files with this name: one for the project and one for the "app"
module. Each module has its own build.gradle file, but this project currently has
just one module. You'll mostly work with the module's build.gradle file to configure
how the Gradle tools compile and build your app.
The hardware profile defines the characteristics of a device as shipped from the factory.
The AVD Manager comes preloaded with certain hardware profiles, such as Pixel
devices, and you can define or customize the hardware profiles as needed.
A system image labeled with Google APIs includes access to Google Play services. A
system image labeled with the Google Play logo in the Play Store column includes the
Google Play Store app and access to Google Play services, including a Google Play tab in
the extended controls dialog that provides a convenient button for updating Google Play
services on the device.
The AVD has a dedicated storage area on your
development machine. It stores the device user data,
such as installed apps and settings, as well as an
emulated SD card. If needed, you can use the AVD
Manager to wipe user data, so the device has the
same data as if it were new
Hello world in
android :-
Omar Magdy
12
13 Android app development
the developer. The creation of this app basically means that the developer can
successfully create a project using android studio.
Steps:
Omar Magdy
13
14 Android app development
2. After pressing next a new window should appear in which you specify the
devices and the minimum required android OS API.
Omar Magdy
14
15 Android app development
3. The next window is the activity selection window where usually the main
(primary) activity is selected.
Omar Magdy
15
16 Android app development
4. The 4th window is responsible for selecting the activity and its layout’s
names.
5. After some processing a new window should appear with the layout
design tab. The layout is the UI that the user interacts with which can be
customized by adding the components using the design tab or by
inserting the components and their parameters as lines of code in the
text tab.
Omar Magdy
16
17 Android app development
Omar Magdy
17
18 Android app development
6. After pressing run from the toolbar the AVD selection appears.
Omar Magdy
18
19 Android app development
Omar Magdy
19
20 Android app development
The android life cycle is usually a 4-step cycle that most applications have to
go through during which several unique actions are performed in every
cycle. It consists of four override methods
onCreate():Called then the activity is created. Used to initialize the
activity, for example create the user interface.
onResume():Called if the activity get visible again and the user starts
interacting with the activity again. Used to initialize fields, register listeners,
bind to services, etc.
onPause():Called once another activity gets into the foreground. Always
called before the activity is not visible anymore. Used to release resources or
save application data. For example you unregister listeners, intent receivers,
unbind from services or remove system service listeners.
onStop():Called once the activity is no longer visible. Time or CPU
intensive shut-down
Omar Magdy
20
21 Android app development
Activities in android :-
Activities are java codes that support the UI. They are basically what every user can
do in the application without editing the code itself such as: dialing numbers, taking
photos, sending mail. They contain most of the code needed to run the application
and in terms of visuals it can be edited from the layout resource folder.
Omar Magdy
21
22 Android app development
Omar Magdy
22
23 Android app development
Location manager
A location manager is a service which uses the device’s GPS in order. This class
provides access to the system location services. These services allow applications
to obtain periodic updates of the device's geographical location. A device’s
location is usually obtained using 3 methods: the location of the closest signal
tower, the location of the router if the device is using its wireless network, or by
triangulating the device’s location via 16 satellites orbiting the earth.
Location managers require permission to access the coarse and fine locations of
the device which can be entered in the manifests file.
The Service can be used for example to show the user his location whenever he walks a
certain distance during a certain period. Conditions can change according to the changes
in the device itself such as: change in the location or changes in the provider’s status.
Broadcast Receiver
Broadcast receiver is an Android component which allows you to send or receive
Android system or application events. All the registered applications are notified by the
Android runtime once event happens.
Similar to location services, sometimes they require a special permission or
Permission to use a feature to monitor changes in the device and its
android OS which are entered
Omar Magdy
23
24 Android app development
Omar Magdy
24
25 Android app development
For example, Broadcast receivers can monitor battery percentage and take actions based
on that change such as changing color or displaying a pop-up with the battery
percentage shown
Omar Magdy
25
26 Android app development
The Values folder contains all the Strings, colors and styles used in the application.
Strings:
A string resource provides text strings for your application with optional text styling and
formatting
Styles:
A style resource defines the format and look for a UI. A style can be applied to an
individual View (from within a layout file) or to an entire Activity or application (from
within the manifest file).
Omar Magdy
26
27 Android app development
Colors:
Color resource contains all the colors used in the application which can be used in the
application. The colors can be used to change all the applications assets in the UI like
background, buttons and text color.
Android uses standard RGB (red, green and blue) color model. Each primary color value
is usually represented by hexadecimal number. At the beginning of such a color
definition you have to put a pound character (#).
The simplest is just #RGB format, where #000 is black and #FFF is white. But in this
format we have only 16 values per color so it gives 4096 combinations. That’s why
#RRGGBB format is mainly used. In this format we have 256 values per primary color, so
16 777 216 colors in total. Black is #000000 and white is #FFFFFF.
Omar Magdy
27
28 Android app development
2. In the main activity layout file add a button, a text view and a text box and give
them IDs.
Omar Magdy
28
29 Android app development
3. In the main activity identify the button, text view and textbox.
5. In the OnClick Override method, the entered string name is received and
transformed into string. The entered name in the text box is then copied to the
text view and a “hello” is added before the name.
Omar Magdy
29
30 Android app development
Omar Magdy
30
31 Android app development
Omar Magdy
31
32 Android app development
This app is used to cycle between 3 background colors using three methods: The
location manager, Broadcast receiver and a single button using an onclick listener.
Steps:
1. Create a new project with a blank activity.
3. In the manifests file add permission to access the coarse and fine location.
Omar Magdy
32
33 Android app development
4. Identify the layout & button in the main activity and set an onclick listener for the
button and an integer.
6. State the condition that if the integer changes in value the background is
changed and if the integer excceds a certain value the integer goes back to its
Omar Magdy
33
34 Android app development
7. For the location manager method, a service isn’t needed since the process isn’t
required to run in the background. So the location manager should be identified
in the main activity along with the conditions on status change.
Omar Magdy
34
35 Android app development
8. Add a broadcast listener with the condition of changing color on battery level
change.
Conclusion :-
At the end of the training period trainees should be able to create simple apps
and understand the coding and the logic behind the processes. New and
innovative ways of thinking are introduce to the trainees to help them deal with
everyday problems using android applications that they developed.
The course introduced most of the android studio’s basic functions and simple
java codes. Data types and control flow statements are introduced in addition to
several override methods. The basic functionalities and the UI of the Android
studio and the Android virtual device are explained by the instructor.
Resources folder is explained along with its values subfolder including the style,
color and string subfolders.
Several practical examples are introduced in the course including a simple “hello
world” app, a greeting app and a changing background app.
Omar Magdy
35
36 Android app development
Refrences :-
www.dre.vanderbit.edu
en.wikipedia.com
www.tutorialspoint.com
www.quora.com
www.androidcentral.com
developers.android.com
www.youtube.com
Omar Magdy
36
37 Android app development
Omar Magdy
37
38 Android app development
Omar Magdy
38