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

Fundamentals-Course-Concepts-V2/: Android Programming

Android programming allows developers to create applications for Android devices like mobile phones and tablets. It provides an SDK to build app modules. The development process involves creating a new project, defining layouts, writing code in Java, building and running the app on an emulator, testing it, and then publishing the app. Key aspects of Android include activities, services, broadcasts, intents, views and layouts. Activities display the app's UI and are started via intents. Services run in the background. Broadcasts allow apps to send and receive messages. Views are UI elements and layouts organize them on screen.

Uploaded by

BAIRENI SUMANTH
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
133 views

Fundamentals-Course-Concepts-V2/: Android Programming

Android programming allows developers to create applications for Android devices like mobile phones and tablets. It provides an SDK to build app modules. The development process involves creating a new project, defining layouts, writing code in Java, building and running the app on an emulator, testing it, and then publishing the app. Key aspects of Android include activities, services, broadcasts, intents, views and layouts. Activities display the app's UI and are started via intents. Services run in the background. Broadcasts allow apps to send and receive messages. Views are UI elements and layouts organize them on screen.

Uploaded by

BAIRENI SUMANTH
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 24

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

Broadcast services: Broadcast is an android device sending


messages to the applications. The app requires the message will
take into action and otherwise ignore
Content provider: content provider is used to send the message to
one application to another application
View:
View is nothing but user interface. Elements that are the screen is
view
Intent:
Each activity start or activated with an intent, intent which is used
to request android runtime to connect activity or the other app
conmponent
Intent is two types
Explicit intent
Implicit intent
Explicit intent:
Android architecture :
Android architecture contains different components to support
different android devices .android software contain open source
Linux kernel having the number of libraries c/c++ which exposed
through application framework
Amoung all the components Linux kernel provides operating
system function to smart phones and dalvic virtual machine
(DVM) provides platform to run android application
The main componets android architecture are
Application
Application framework
Android runtime
Platfrom libraries
Linux kernel
Applications :
Applications is top of the archetechture of android. The pre
installed application like home, calendar, contacts, clock, gallery
and third party application download from the playstore.
All these application run with the android with the help of the
Android run time
How install an emulator:
In this we will know how to install an apk in android studio. There
are several methods to do this but most of them are unreliable.
Open emulator:
The first step is open android studio and open emulator.here we
can see different apk that we are going to install . before going to
install we have to check that apk has advanced or not.

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 −

Feature & Description


1.Beautiful UI
Android OS basic screen provides a beautiful and intuitive user interface.

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.

6) In 2007, Google announces the development of android OS.

7) In 2008, HTC launched the first android mobile.

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.

Constants of Toast class

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.

Life cycle of activity:


Intent:
Intent is messaging an object .
They are two types
1.explicit intent
2.implicit intent
Explicit intent:
Explicit intent connecting the inner world application. If u want
connect one activity to another activity we can use intent quotes
combine them, below image connecting first activity to second
activity by clicking button.

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

Android Layout is used to define the user interface that holds the UI


controls . Generally, every application is a combination of View and
ViewGroup. As we know, an android application contains a large
number of activities and we can say each activity is one page of the
application. So, each activity contains multiple user interface
components and those components are the instances of the View and
ViewGroup. All the elements in a layout are built using a hierarchy
of View and ViewGroup objects.

View

A View is defined as the user interface which is used to create


interactive UI components such
as TextView, ImageView, EditText, RadioButton, etc., and is
responsible for event handling and drawing. They are Generally
Called Widgets.

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

Autocompletetextview control in ativity file:


We can create autocompletetextview control progrmatically to show
list of items based on the user entered text.
Ex:
Linear_layout=(linear layout)findviewbyid(R.id.Linar_layout);
Autocompletetextview actv=new Autocompletetextview();
Linar_lauyout.addview(actv);
Set auto complete text view in activity file:
In android we can set a text in autocompletetextview control by
using setadapter() method.
This is example for the auto completetextview:
String[] countries={“india”,”usa”,”uk”,”iran”,”Italy”};
Arrayadapter<string> adapter=new
arrayadapter<String>(this,R.layout.simple_item_list,countries);
Autocompletetextview
actv=( Autocompletetextview)findviewbyid(R.id.autocontries);
actv.setadapter(adpter);
spinner:
spinner provides quick way to select a list of values from set. In
default state,it shows the currently selected one. To touch on
spinner it show dropdown menu with list of values from which user
can select the option.
Key class for spinner:
1.spinner
2.spinneradapter
3.adapterview.onsetclickonlister
The choices you provide for the spinner can come from any
resource,but it come across through the spinneradapter such as
array adapter
Spinner adapter:
Spinner spinner=(Spinner)findviewbyid(R.id.simple_spinner);
Arrayadapter<String>
adapter=Arrayadpater.createfromresource(R.id.simple_spinner_item
);
adapter.onsetdropdownresource(R.id.simple_spinner_dropdown_ite
m);
spinner.setadapter(adapter);
adapterview.onitemselectlistner:
Spinner spinner=(spinner)findviewbyid(R.id.spinner);
Spinner.setonitemselectedlistner(this);

Webview:

Webview is a view that display web pages inside your application.we


can also add HTML string and show it in the inside our application. By
using webview, webview turns into web application
In order to add web view to our application , we need to add
webview to layout file that is xml file.
<webview
xmlns:android="http://schemas.android.com/apk/res/android"

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”);

In order to load url of webpage of webview . this is page is not


loaded in the webview. In order to do this we need to extend class
from the webviewclient and override the class.
Syntax:
Protectd class mybrowser extendents webviewclient
{
@override
Public overridetheurl(webview view,url string)
{
View.loadurl(url);
Return view;
}

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,

You might also like