Fundamentals-Course-Concepts-V2/: Android Programming
Fundamentals-Course-Concepts-V2/: Android Programming
https://google-developer-training.github.io/android-developer-
fundamentals-course-concepts-v2/
what is android:
Android programming is operating system and programming
platform for different devices like mobile phones and tablets.
Android provides (SDK) software development kit to assemble
modules for user to create the different apps. Android programming
is ecosystem
Developers have a variety of reasons to develop applications. They
may develop to address the business or different service and may
offer games and other type of contents to the user. By developing in
the android why because most of the people using the android
mobile if they develop in the android programingn there are no
complication to the user while using it.
development process:
creating new project
define layouts
write code
build and run
test and debug
publish the app
1. Creating new project then take an appropriate templets
2. Define layouts for each screen that has UI .you can also define
ui by using the code
3. Write the code by using the java
4. Build and run the app’s on virtual device
5. Test the app’s on virtual device how it works and also how it is
useful
6. Publish the app by assembling APk
View:
The UI consisting of hierarchy of objects called view ,every
element on the screen is view. The view class consisting basic
building block of all UI
The elements on the UI is called the view
Text view
Edit view
Button view(radio,check box,\
Image view
Scroll view
Layouts
Linear view or
constraint view
Relative view
Basic building block of android:
application framework .
Application framework:
Application framework provides different componets to run the
user application.
Application frame contain main activity, notification activity,
package activity, windows activity which are helpful for the user
applications.
Android framework:
Activity: activity is java class containing the code a
Activity is two types
1.layout activity
2.main activity
Services:
Services mainly for the background
There are two types of services to the user
Foreground
Background
Project structure:
After complete setup of architecture of android . we need to
create android application. In android studio we have to take new
project for the each application.
The android project application contain app modules and code
source files and
Manifest folder
Java folder
Res(resources file) folder
Graddle scripts
Manifest folder:
Manifest folder contain the androidmanifest.xml for creating the
android application. This file containing the information about the
application such as source code, meta data.
Manifest act as intermediate between the android OS and user
application.
Java folder :
Java folder contain the java and kotlin source code (files) and files
that are used for the application development. If we take a new
project by using the java, by default a class file manifest.java will
created and all package related to that java will appear
Res (resource)folder:
Res folder is the most important folder , it contain non code sources
like images,xml layouts and UI for the development application
Res/drawable
Res/layout
Res/midmap
Res/values
Gradle script folder:
In Gradle means automated build system which contain number of
files which are used to build the configuration which can be applied
to all modules in our application.
Feature of the android:
It is an open source
Anyone can customize the android application
There is plelty of application that are choosen by the consumer
Q.Features of Android
Android is a powerful operating system competing with Apple 4GS and supports great features. Few
of them are listed below −
2.Connectivity
GSM/EDGE, IDEN, CDMA, EV-DO, UMTS, Bluetooth, Wi-Fi, LTE, NFC and WiMAX.
3.Storage
SQLite, a lightweight relational database, is used for data storage purposes.
4.Media support
H.263, H.264, MPEG-4 SP, AMR, AMR-WB, AAC, HE-AAC, AAC 5.1, MP3, MIDI, Ogg Vorbis, WAV,
JPEG, PNG, GIF, and BMP.
5.Messaging
SMS and MMS
6.Web browser
Based on the open-source WebKit layout engine, coupled with Chrome's V8 JavaScript engine
supporting HTML5 and CSS3.
7.Multi-touch
Android has native support for multi-touch which was initially made available in handsets such as the
HTC Hero.
8.Multi-tasking
User can jump from one task to another and same time various application can run simultaneously.
Q.History of Android
The history and versions of android are interesting to know. The code names of android ranges from
A to J currently, such as Aestro, Blender, Cupcake, Donut, Eclair, Froyo, Gingerbread, Honeycomb, Ice
Cream Sandwitch, Jelly Bean, KitKat and Lollipop. Let's understand the android history in a sequence.
1) Initially, Andy Rubin founded Android Incorporation in Palo Alto, California, United States in
October, 2003.
2) In 17th August 2005, Google acquired android Incorporation. Since then, it is in the subsidiary of
Google Incorporation.
3) The key employees of Android Incorporation are Andy Rubin, Rich Miner, Chris White and Nick
Sears.
4) Originally intended for camera but shifted to smart phones later because of low market for
camera only.
5) Android is the nick name of Andy Rubin given by coworkers because of his love to robots.
Ui layout:
The layout in android programming it is used to define the user
interface and that holds the UI control and wedgets of an android
application or screen activity.
Basically android is combination of view and view group.
View:
A view is user interface that can be used to create interactive
componets of layout such as
There are four types of view
Text view
Image view
Edit view
Radio button view
Layouts:
The view group is base class for the layouts and layout components
of the view and view group.
Types of layouts:
Linear layout
Relative layout
Constraint layout
Linear layout:
Linear layout is used to define view group subclass, it is used to
create child view elements either horizontally or vertically based on
the orientation
Relative layout:
Relative layout is used to define the view group subclass, it is used to
define the position of the subclass of child view elements in relative
to each other(a is to the right of b) or relative to parent class.
Constraint layout:
Constraint layout is view group subclass, it is used to specify the
position of layouts constraint for each child view related to the view
present.it is similar to relative layout
Table layout:
Table layout is view group subclass, it is used to display the child
view elements in row and column layout
Web view:
Web view is browser that is used to display the browser in our
activity
List view:
List view is view group, it is used to display the list of scrollable child
elements in a column.
Android Toast
Android Toast can be used to display information for the short period of time. A
toast contains message to be displayed quickly and disappears after sometime.
Toast class
Toast class is used to show notification for a particular interval of time. After
sometime it disappears. It doesn't block the user interaction.
There are only 2 constants of Toast class which are given below.
Constant Description
public static final int LENGTH_LONG displays view for the long duration of time.
public static final int LENGTH_SHORT displays view for the short duration of time.
Unit 2
Activity :
An activity is single screen with the user interface just like windows.
If you worked the c,c++ languages then you have seen that the
programe start from the main function. Very similarly android
programe initialize with the activity start with the call onCreate
callback methods. There is sequence of callback method to start an
activity and there is sequence of callback methods to stop an activity.
Second activity
First activity
Here is your
Click
second application
Implicit intent:
If u want connect one activity to another activity in implicit intent it
done automatically. By writing code in the mainactivity.java activity.
Android UI Layouts or UI COMPONETNS
View
View
A ViewGroup act as a base class for layouts and layouts parameters that hold other
Views or ViewGroups and to define the layout properties. They are Generally Called
layouts.
ViewGroup
Attributes
Every View and ViewGroup object supports their own variety of XML attributes. Some
attributes are specific to a View object (for example, TextView supports
the textSize attribute), but these attributes are also inherited by any View objects that
may extend this class. Some are common to all View objects, because they are
inherited from the root View class (like the id attribute). And, other attributes are
considered "layout parameters," which are attributes that describe certain layout
orientations of the View object, as defined by that object's parent ViewGroup object.
Attributes of view:
View have properties that define the where view appears on the
activity, view size and it background . while defining view in xml file
these properties consider as the view attributes
Syntax for the attribute:
Android:attribute_name=”value”
For example:
Android:id=”@+id/tv”
Android:layout_width=”match_parent”
Android:layout_height=”match_parent”
Android:orientation=”vertical”
Android:text=”hello”
Android:textsize=”30dp”
Android:textcolor=”#f11”
Text view: the text view is user control interface which can be used
to display the text
Autocomplete text view:
Edit view:
The edit view is user control interface which be used to enter or
modify the user text
Auto complete Text view:
Auto complete view is editable text view which is used to show list of
suggestion from user entered text .which can be shown as the drop
down menu which user can choose an item from list of items.
Auto completetextview is subclass of the edittextview so we can
inherit all the properties of edittext based on the user requirements.
choose the country:
i
italy
india
Webview:
android:id=”@+id/wb”
android:layout_width=”fill_parent”
android:layout_height=”fill_parent”/>
in order use it , we need create reference in java file. In order to
create reference , create an object for the class webview
Webview webview=(webview)findviewbyid(R.id.wb);
In order to load weburl into webview , we need to load that using
the method called loadUrl(string url).
Browser.loadUrl(“http//www.facebook.com”);
Enter text
click
http//www.facebook.com
click
Fragments:
Android Fragment is the part of activity, it is also known as sub-activity. There can
be more than one fragment in an activity. Fragments represent multiple screen inside
one activity.
Fragment lifecycle:
Each fragment instance has own lifecycle, when user navigate and
interact with your app, your app transition through various states of
a lifecycle.
To use fragment lifecycle ,fragments implements Lifecycleowner, the
object is lifecycle that can be accessed through the getLifecycle()
method
Life cycle of fragments:
Initialized
Created
Started
Resumed
Destroyed
As an alternate to use lifecycleobserver, fragment class includes
callback methods to corresponding to the each changes in the
lifecycle of a fragment.
These methods are
onCreate(),onStart(),onResume(),onPause(),onDestroy,