SlideShare a Scribd company logo
1 of 24
Download to read offline
Android Application
Development Session-2
From Beginner to Advanced
By : Ahesanali Suthar
email:ahesanali.suthar@gmail.com
Topics Covered
1.

Android Framework (Activity,Service,Broadcastreceiver,Content Providers)

2.

Android Layout

3.

Basic UI Widgets (Button,TextBox,Choice Box)
1. Android Framework
●

Android App framework have four basic components which are listed
below
1.
2.

Service.

3.

Broadcast Receiver.

4.
●

Activity.

Content Providers

We will see each component in small detail
1. Android Framework
1.

Activity:
● An Activity is an application component that provides a screen with
which users can interact in order to do something, such as dial the
phone, take a photo, send an email, or view a map
●

Each activity is given a window in which to draw its user interface.
The window typically fills the screen.

●

Activity handle events in short for a windows .NET programer Activity
is a code that is generated when we place button in form and double
click on it and Visual Studio IDE generate button1_click() method or
function.

●

Activity decides which Screen(in android terminology it's call View) to
be diaplayed. We are designing the screen in xml fomrat as we seen
in Hello word case we have main.xml which is view for hello word
activity.
1. Android Framework:
Activity
●

In Activity code we setting up the view we have to write following code.
setContentView(R.layout.main);

●

Please note that we have to just mention R.layout.main not R.layout.
main.xml.
As discussed earlier(First PPT) please note that what ever views we are
creating for screen, we are putting it in res/layout folder.

●

●

There can be more than one activity in the app, and all activity must be
declared in the manifest file as follow.
<activity
android:name =".HelloWorldActivity"
android:label ="@string/app_name" >
<intent-filter >
<action android:name ="android.intent.action.MAIN" />
<category android:name ="android.intent.category.LAUNCHER"
/>
</intent-filter >
</activity>
1. Android Framework:
Activity
●

To declare activity in manifest file only <acivity> and </activity> tag is
enough but please note that in above there is also a <intent-filter> tag and
inside intent-filter there is action and category tag. This is for declaring the
activity which runs first when app is started. So from the category we can
figure out that this is the LAUNCHER activity.

●

We can set only one activity as a launcher activity.

●

To read More About Activity Please read:http://developer.android.
com/guide/components/activities.html
1. Android Framework:
Activity
1. Android Framework:
Service
2. Service:
●

Service is an application components that will run in background and do
not have user-interface.

●

Service is executing in background and provide result to activity so activity
updates the user-interface.

●

To user service in application we must have to register service in the
manifest file like activity.

●

To start service from activity Context.startService() is used.
1. Android Framework:
Broadcast Receiver
3. Broadcast Receiver:
●

Android broadcast event when ever some specified actions like call state is
changed (Incoming,outgoing),New Message,Battery is low etc.

●

So broadcast receiver is the application component which receives these
broadcast.

●

To use broadcast receiver we have to declare it in android.manifest or we
can register/unregister it from activity code.

<uses-permission
<receiver

android:name ="android.permission.READ_PHONE_STATE" />

android:name =".BootReceiver">
<intent-filter >
<action android:name ="android.intent.action.
BOOT_COMPLETED" />
</intent-filter >
</receiver>
1. Android Framework:
Service
●

So when ever phone state is changed from IDLE to RINGING our
broadcast receiver is called and we can handle the event.

●

Normally broadcast receiver have less time for execution so we should not
have to do processing much in broadcast receiver instead we should have
to start serivce and have more processing in service code.
1. Android Framework:
Content Providers
4. Content Providers:
●

Content Providers are used for data operations like storing and retrieving
the data.

●

Content providers manage access to a structured set of data. They
encapsulate the data, and provide mechanisms for defining data security .

●

Content providers are the standard interface that connects data in one
process with code running in another process. In short content provider
are more or less same like class any driver which we are normally using
database connection.

●

To read more about content provider please check link:http://developer.
android.com/guide/topics/providers/content-provider-basics.html
2. Android Layouts
●
●

●
●

A layout defines the visual structure for a user interface, such as the UI for
an activity or app widget. You can declare a layout in two ways:
Declare UI elements in XML. Android provides a straightforward XML
vocabulary that corresponds to the View classes and subclasses, such as
those for widgets and layouts.
Instantiate layout elements at runtime. Your application can create View
and ViewGroup objects (and manipulate their properties) programmatically
Common Layout used in app design
1. Linear Layout
2. Relative Layout
3. List View
4. Grid View
2. Android Layouts
1.

Linear Layout : To create linear layout we need to add below code in
layout xml file.Using linear layout we can put other controls either vertically
or horizontally which we can define by android:orientation attribute.
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:paddingLeft="16dp"
android:paddingRight="16dp"
android:orientation="vertical" ></LinearLayout >
2. Android Layouts
2.Relative Layout : is a view group that
displays child views in relative positions. The
position of each view can be specified as
relative to sibling elements.
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.
com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:paddingLeft="16dp"
android:paddingRight="16dp" >
<EditText
android:id="@+id/name"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:hint="@string/reminder" />

<Spinner
android:id="@+id/dates"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_below="@id/name"
android:layout_alignParentLeft="true"
android:layout_toLeftOf="@+id/times" />
<Spinner
android:id="@id/times"
android:layout_width="96dp"
android:layout_height="wrap_content"
android:layout_below="@id/name"
android:layout_alignParentRight="true" />
<Button
android:layout_width="96dp"
android:layout_height="wrap_content"
android:layout_below="@id/times"
android:layout_alignParentRight="true"
android:text="@string/done" />
2. Android Layouts
2. Android Layout
3.Listview : ListView is a view group that displays a list of scrollable items. The
list items are automatically inserted to the list using an Adapter that pulls
content from a source such as an array or database query.
●

Lets take an example of network list displayed where we have to display
custom type of item.
2. Android Layout
Mian Activty Layout screen
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="@dimen/activity_vertical_margin" android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
tools:context=".Network" >
<ListView
android:id="@+id/lvNetworkList"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:scrollbars="vertical" >
</ListView>
</RelativeLayout>
2. Android Layout
List View Item Detail Desig
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.
com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="fill_parent" >
<TextView
android:id="@+id/txtNetworkName"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:layout_marginLeft="20dp"
android:layout_marginTop="22dp"
android:text="@string/network_name"
android:textAppearance="?android:attr/textAppearanceLarge"

<TextView
android:id="@+id/txtPortType"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBaseline="@+id/txtNetworkType"
android:layout_alignBottom="@+id/txtNetworkType"
android:layout_alignParentRight="true"
android:layout_marginRight="22dp"
android:text="@string/port_type"
android:textColor="#AAA"
android:textAppearance="?android:
attr/textAppearanceMedium" />
<TextView
android:id="@+id/txtNetworkDscr"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="@+id/txtNetworkName"
android:layout_alignRight="@+id/txtPortType"
android:layout_below="@+id/txtNetworkName"
android:text="@string/port_type"
android:textColor="#AAA"
android:textAppearance="?android:attr/textAppearanceSmall"

/>
<TextView
android:id="@+id/txtNetworkType"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="@+id/txtNetworkName"
android:layout_below="@+id/txtNetworkName"
android:layout_marginTop="21dp"
android:text="@string/network_type"
android:textColor="#AAA"
android:textAppearance="?android:
attr/textAppearanceMedium" />

/>
</RelativeLayout>
2. Android Layout
Atcivity Code for Initialize listview
LayoutInflater inflater = (LayoutInflater)
context
private ListView lvNetworkListCode = (ListView) findViewById(R.id.
lvNetworkList);
public ArrayList<NetworkModel> Networks = new
ArrayList<NetworkModel>();
lvNetworkListCode.setAdapter(adapter);
ItemAdapter adapter = new ItemAdapter(this,R.layout.network_item,
Networks);
●

Here NetworkModel is the model class have attributes of
single item.
●
ItemAdapter class is the important it has getView method
which will iterate on models arraylist and print one byone item.
private final Context context;
private ArrayList<NetworkModel> Ids;
private final int rowResourceId;
public ItemAdapter(Context context, int resource,
ArrayList<NetworkModel> objects) {
super(context, resource, objects);
this.context = context;
this.Ids = objects;
this.rowResourceId = resource;
}

.getSystemService(Context.
LAYOUT_INFLATER_SERVICE);
View rowView = inflater.inflate
(rowResourceId, parent, false);
txtNwNameCode = (TextView) rowView.
findViewById(R.id.txtNetworkName);
txtNwDscrCode = (TextView) rowView.
findViewById(R.id.txtNetworkDscr);
txtNwTypeCode = (TextView) rowView.findViewById(R.id.
txtNetworkType);
txtPortTypeCode = (TextView) rowView.
findViewById(R.id.txtPortType);
if (Ids.size() > 0) {
// setting values from model
txtNwNameCode.setText(Ids.get
(position).getNetworkName());
txtNwDscrCode.setText(Ids.get
(position).getNetworkDescr());
txtNwTypeCode.setText("N/W Type:
"+Ids.get(position).getNetworkType());
txtPortTypeCode.setText("Port Type:
"+Ids.get(position).getPortType());

@Override
public View getView(int position, View convertView,
ViewGroup parent) {

}
return rowView;
3. Basic UI Widgets
●
●

In section we will see how to add basic UI controls like text-box,label,
button and checkbox.
Lets consider below UI if we wanted to design.
3. Basic UI Widgets
Layout Design
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.
com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="@string/enterNameLable" />
<EditText
android:id="@+id/nameTxt"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:hint="@string/enterNameHint" />
<CheckBox
android:id="@+id/appendHelloCheck"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="@string/appendHello" />
<RadioGroup
android:id="@+id/radioGroup"
android:layout_width="fill_parent"
android:layout_height="wrap_content">
<RadioButton
android:id="@+id/maleradio"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="@string/maleLbl"/>

<RadioButton
android:id="@+id/femaleradio"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="@string/femaleLbl" />
</RadioGroup>
<Button
android:id="@+id/showDataBtn"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="@string/okBtnTxt" />
<TextView
android:id="@+id/resultText"
android:layout_width="fill_parent"
android:layout_height="wrap_content" />
<ImageView
android:src="@drawable/maktabah"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:contentDescription="@+string/Image" />
</LinearLayout>
3. Basic UI Widgets
Activity Code:

OnClickListener showDataClickListener =new OnClickListener() {

public class Tutorial1Activity extends Activity {

@Override
public void onClick(View v) {

private Button showDataBtn;
String userName = userNametxt.getText().
private EditText userNametxt;
private CheckBox appendCheck;
private RadioGroup maleFemaleRadioGroup;
private TextView resultantText;
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.screen1);
initViewCOntrols();
}
public void initViewCOntrols()
{
userNametxt = (EditText) findViewById(R.id.nameTxt);
appendCheck = (CheckBox) findViewById(R.id.
appendHelloCheck);
maleFemaleRadioGroup = (RadioGroup) findViewById(R.id.
radioGroup);

toString();
if(userName.length()>0){
RadioButton maleFRadio =
(RadioButton) findViewById(maleFemaleRadioGroup.
getCheckedRadioButtonId());
if(appendCheck.isChecked()){
resultantText.setText("Hello
"+userName+" n You are"+maleFRadio.getText().toString());
}else
{
resultantText.setText
(userName+" n You are"+maleFRadio.getText().toString());
}
}else
{
userNametxt.setError("Please Enter
Name.");
}

showDataBtn = (Button) findViewById(R.id.showDataBtn);
resultantText = (TextView) findViewById(R.id.resultText);

}
};

showDataBtn.setOnClickListener(showDataClickListener);
}

}
Questions?
Android App Development From Beginner to Advanced

More Related Content

What's hot

Android Fundamental
Android FundamentalAndroid Fundamental
Android FundamentalArif Huda
 
Londroid Android Home Screen Widgets
Londroid Android Home Screen WidgetsLondroid Android Home Screen Widgets
Londroid Android Home Screen WidgetsRichard Hyndman
 
Android application-component
Android application-componentAndroid application-component
Android application-componentLy Haza
 
Android development orientation for starters v4 seminar
Android development orientation for starters v4   seminarAndroid development orientation for starters v4   seminar
Android development orientation for starters v4 seminarJoemarie Amparo
 
Day 15: Working in Background
Day 15: Working in BackgroundDay 15: Working in Background
Day 15: Working in BackgroundAhsanul Karim
 
Introduction to android
Introduction to androidIntroduction to android
Introduction to androidShrijan Tiwari
 
android layouts
android layoutsandroid layouts
android layoutsDeepa Rani
 
Day 3: Getting Active Through Activities
Day 3: Getting Active Through ActivitiesDay 3: Getting Active Through Activities
Day 3: Getting Active Through ActivitiesAhsanul Karim
 
View groups containers
View groups containersView groups containers
View groups containersMani Selvaraj
 
Android Development Made Easy - With Sample Project
Android Development Made Easy - With Sample ProjectAndroid Development Made Easy - With Sample Project
Android Development Made Easy - With Sample ProjectJoemarie Amparo
 
Android tutorial
Android tutorialAndroid tutorial
Android tutorialkatayoon_bz
 
Android tutorial
Android tutorialAndroid tutorial
Android tutorialEd Zel
 
What is Android?
What is Android?What is Android?
What is Android?ndalban
 
Android Development: Build Android App from Scratch
Android Development: Build Android App from ScratchAndroid Development: Build Android App from Scratch
Android Development: Build Android App from ScratchTaufan Erfiyanto
 

What's hot (20)

Android Fundamental
Android FundamentalAndroid Fundamental
Android Fundamental
 
Londroid Android Home Screen Widgets
Londroid Android Home Screen WidgetsLondroid Android Home Screen Widgets
Londroid Android Home Screen Widgets
 
Android application-component
Android application-componentAndroid application-component
Android application-component
 
Android UI
Android UIAndroid UI
Android UI
 
Ppt 2 android_basics
Ppt 2 android_basicsPpt 2 android_basics
Ppt 2 android_basics
 
Android development module
Android development moduleAndroid development module
Android development module
 
Android UI Fundamentals part 1
Android UI Fundamentals part 1Android UI Fundamentals part 1
Android UI Fundamentals part 1
 
Android development orientation for starters v4 seminar
Android development orientation for starters v4   seminarAndroid development orientation for starters v4   seminar
Android development orientation for starters v4 seminar
 
Day 15: Working in Background
Day 15: Working in BackgroundDay 15: Working in Background
Day 15: Working in Background
 
Introduction to android
Introduction to androidIntroduction to android
Introduction to android
 
android layouts
android layoutsandroid layouts
android layouts
 
Day 3: Getting Active Through Activities
Day 3: Getting Active Through ActivitiesDay 3: Getting Active Through Activities
Day 3: Getting Active Through Activities
 
Android
AndroidAndroid
Android
 
View groups containers
View groups containersView groups containers
View groups containers
 
Android Development Made Easy - With Sample Project
Android Development Made Easy - With Sample ProjectAndroid Development Made Easy - With Sample Project
Android Development Made Easy - With Sample Project
 
Android tutorial
Android tutorialAndroid tutorial
Android tutorial
 
Android tutorial
Android tutorialAndroid tutorial
Android tutorial
 
Android tutorial
Android tutorialAndroid tutorial
Android tutorial
 
What is Android?
What is Android?What is Android?
What is Android?
 
Android Development: Build Android App from Scratch
Android Development: Build Android App from ScratchAndroid Development: Build Android App from Scratch
Android Development: Build Android App from Scratch
 

Similar to Android App Development From Beginner to Advanced

Hello android world
Hello android worldHello android world
Hello android worldeleksdev
 
Android terminologies
Android terminologiesAndroid terminologies
Android terminologiesjerry vasoya
 
Introduction to Android Development
Introduction to Android DevelopmentIntroduction to Android Development
Introduction to Android DevelopmentAly Abdelkareem
 
Lecture #1 Creating your first android project
Lecture #1  Creating your first android projectLecture #1  Creating your first android project
Lecture #1 Creating your first android projectVitali Pekelis
 
Android Apps Development Basic
Android Apps Development BasicAndroid Apps Development Basic
Android Apps Development BasicMonir Zzaman
 
Creating the first app with android studio
Creating the first app with android studioCreating the first app with android studio
Creating the first app with android studioParinita03
 
Android 101 Session @thejunction32
Android 101 Session @thejunction32Android 101 Session @thejunction32
Android 101 Session @thejunction32Eden Shochat
 
Kotlin for Android App Development Presentation
Kotlin for Android App Development PresentationKotlin for Android App Development Presentation
Kotlin for Android App Development PresentationKnoldus Inc.
 
Android interview questions and answers
Android interview questions and answersAndroid interview questions and answers
Android interview questions and answerskavinilavuG
 
Mobile Application Development With Android
Mobile Application Development With AndroidMobile Application Development With Android
Mobile Application Development With Androidguest213e237
 
Android Development : (Android Studio, PHP, XML, MySQL)
Android Development : (Android Studio, PHP, XML, MySQL)Android Development : (Android Studio, PHP, XML, MySQL)
Android Development : (Android Studio, PHP, XML, MySQL)Kavya Barnadhya Hazarika
 
Android training day 2
Android training day 2Android training day 2
Android training day 2Vivek Bhusal
 
Android developer interview questions with answers pdf
Android developer interview questions with answers pdfAndroid developer interview questions with answers pdf
Android developer interview questions with answers pdfazlist247
 

Similar to Android App Development From Beginner to Advanced (20)

Android Basic- CMC
Android Basic- CMCAndroid Basic- CMC
Android Basic- CMC
 
Hello android world
Hello android worldHello android world
Hello android world
 
Notes Unit3.pptx
Notes Unit3.pptxNotes Unit3.pptx
Notes Unit3.pptx
 
Unit2
Unit2Unit2
Unit2
 
Android terminologies
Android terminologiesAndroid terminologies
Android terminologies
 
Google Android
Google AndroidGoogle Android
Google Android
 
Introduction to Android Development
Introduction to Android DevelopmentIntroduction to Android Development
Introduction to Android Development
 
Lecture #1 Creating your first android project
Lecture #1  Creating your first android projectLecture #1  Creating your first android project
Lecture #1 Creating your first android project
 
Android Apps Development Basic
Android Apps Development BasicAndroid Apps Development Basic
Android Apps Development Basic
 
Creating the first app with android studio
Creating the first app with android studioCreating the first app with android studio
Creating the first app with android studio
 
Android 101 Session @thejunction32
Android 101 Session @thejunction32Android 101 Session @thejunction32
Android 101 Session @thejunction32
 
Kotlin for Android App Development Presentation
Kotlin for Android App Development PresentationKotlin for Android App Development Presentation
Kotlin for Android App Development Presentation
 
Android beginners David
Android beginners DavidAndroid beginners David
Android beginners David
 
Android interview questions and answers
Android interview questions and answersAndroid interview questions and answers
Android interview questions and answers
 
Mobile Application Development With Android
Mobile Application Development With AndroidMobile Application Development With Android
Mobile Application Development With Android
 
Android Introduction
Android IntroductionAndroid Introduction
Android Introduction
 
Android Development : (Android Studio, PHP, XML, MySQL)
Android Development : (Android Studio, PHP, XML, MySQL)Android Development : (Android Studio, PHP, XML, MySQL)
Android Development : (Android Studio, PHP, XML, MySQL)
 
Android training day 2
Android training day 2Android training day 2
Android training day 2
 
Android Development Basics
Android Development BasicsAndroid Development Basics
Android Development Basics
 
Android developer interview questions with answers pdf
Android developer interview questions with answers pdfAndroid developer interview questions with answers pdf
Android developer interview questions with answers pdf
 

Recently uploaded

My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationRidwan Fadjar
 
Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationSlibray Presentation
 
"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr BaganFwdays
 
Build your next Gen AI Breakthrough - April 2024
Build your next Gen AI Breakthrough - April 2024Build your next Gen AI Breakthrough - April 2024
Build your next Gen AI Breakthrough - April 2024Neo4j
 
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
"Federated learning: out of reach no matter how close",Oleksandr LapshynFwdays
 
Key Features Of Token Development (1).pptx
Key  Features Of Token  Development (1).pptxKey  Features Of Token  Development (1).pptx
Key Features Of Token Development (1).pptxLBM Solutions
 
CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):comworks
 
Dev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebDev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebUiPathCommunity
 
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...shyamraj55
 
WordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your BrandWordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your Brandgvaughan
 
Unleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubUnleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubKalema Edgar
 
My INSURER PTE LTD - Insurtech Innovation Award 2024
My INSURER PTE LTD - Insurtech Innovation Award 2024My INSURER PTE LTD - Insurtech Innovation Award 2024
My INSURER PTE LTD - Insurtech Innovation Award 2024The Digital Insurer
 
Understanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitectureUnderstanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitecturePixlogix Infotech
 
Pigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping ElbowsPigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping ElbowsPigging Solutions
 
Unraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfUnraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfAlex Barbosa Coqueiro
 
Transcript: New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024BookNet Canada
 
Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Commit University
 
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticsKotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticscarlostorres15106
 
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationBeyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationSafe Software
 

Recently uploaded (20)

My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 Presentation
 
Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck Presentation
 
"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan
 
Build your next Gen AI Breakthrough - April 2024
Build your next Gen AI Breakthrough - April 2024Build your next Gen AI Breakthrough - April 2024
Build your next Gen AI Breakthrough - April 2024
 
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
 
Key Features Of Token Development (1).pptx
Key  Features Of Token  Development (1).pptxKey  Features Of Token  Development (1).pptx
Key Features Of Token Development (1).pptx
 
CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):
 
Dev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebDev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio Web
 
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
 
WordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your BrandWordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your Brand
 
Unleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubUnleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding Club
 
My INSURER PTE LTD - Insurtech Innovation Award 2024
My INSURER PTE LTD - Insurtech Innovation Award 2024My INSURER PTE LTD - Insurtech Innovation Award 2024
My INSURER PTE LTD - Insurtech Innovation Award 2024
 
Understanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitectureUnderstanding the Laravel MVC Architecture
Understanding the Laravel MVC Architecture
 
Pigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping ElbowsPigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping Elbows
 
Unraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfUnraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdf
 
Transcript: New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024
 
Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!
 
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticsKotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
 
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationBeyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
 
DMCC Future of Trade Web3 - Special Edition
DMCC Future of Trade Web3 - Special EditionDMCC Future of Trade Web3 - Special Edition
DMCC Future of Trade Web3 - Special Edition
 

Android App Development From Beginner to Advanced

  • 1. Android Application Development Session-2 From Beginner to Advanced By : Ahesanali Suthar email:ahesanali.suthar@gmail.com
  • 2. Topics Covered 1. Android Framework (Activity,Service,Broadcastreceiver,Content Providers) 2. Android Layout 3. Basic UI Widgets (Button,TextBox,Choice Box)
  • 3. 1. Android Framework ● Android App framework have four basic components which are listed below 1. 2. Service. 3. Broadcast Receiver. 4. ● Activity. Content Providers We will see each component in small detail
  • 4. 1. Android Framework 1. Activity: ● An Activity is an application component that provides a screen with which users can interact in order to do something, such as dial the phone, take a photo, send an email, or view a map ● Each activity is given a window in which to draw its user interface. The window typically fills the screen. ● Activity handle events in short for a windows .NET programer Activity is a code that is generated when we place button in form and double click on it and Visual Studio IDE generate button1_click() method or function. ● Activity decides which Screen(in android terminology it's call View) to be diaplayed. We are designing the screen in xml fomrat as we seen in Hello word case we have main.xml which is view for hello word activity.
  • 5. 1. Android Framework: Activity ● In Activity code we setting up the view we have to write following code. setContentView(R.layout.main); ● Please note that we have to just mention R.layout.main not R.layout. main.xml. As discussed earlier(First PPT) please note that what ever views we are creating for screen, we are putting it in res/layout folder. ● ● There can be more than one activity in the app, and all activity must be declared in the manifest file as follow. <activity android:name =".HelloWorldActivity" android:label ="@string/app_name" > <intent-filter > <action android:name ="android.intent.action.MAIN" /> <category android:name ="android.intent.category.LAUNCHER" /> </intent-filter > </activity>
  • 6. 1. Android Framework: Activity ● To declare activity in manifest file only <acivity> and </activity> tag is enough but please note that in above there is also a <intent-filter> tag and inside intent-filter there is action and category tag. This is for declaring the activity which runs first when app is started. So from the category we can figure out that this is the LAUNCHER activity. ● We can set only one activity as a launcher activity. ● To read More About Activity Please read:http://developer.android. com/guide/components/activities.html
  • 8. 1. Android Framework: Service 2. Service: ● Service is an application components that will run in background and do not have user-interface. ● Service is executing in background and provide result to activity so activity updates the user-interface. ● To user service in application we must have to register service in the manifest file like activity. ● To start service from activity Context.startService() is used.
  • 9. 1. Android Framework: Broadcast Receiver 3. Broadcast Receiver: ● Android broadcast event when ever some specified actions like call state is changed (Incoming,outgoing),New Message,Battery is low etc. ● So broadcast receiver is the application component which receives these broadcast. ● To use broadcast receiver we have to declare it in android.manifest or we can register/unregister it from activity code. <uses-permission <receiver android:name ="android.permission.READ_PHONE_STATE" /> android:name =".BootReceiver"> <intent-filter > <action android:name ="android.intent.action. BOOT_COMPLETED" /> </intent-filter > </receiver>
  • 10. 1. Android Framework: Service ● So when ever phone state is changed from IDLE to RINGING our broadcast receiver is called and we can handle the event. ● Normally broadcast receiver have less time for execution so we should not have to do processing much in broadcast receiver instead we should have to start serivce and have more processing in service code.
  • 11. 1. Android Framework: Content Providers 4. Content Providers: ● Content Providers are used for data operations like storing and retrieving the data. ● Content providers manage access to a structured set of data. They encapsulate the data, and provide mechanisms for defining data security . ● Content providers are the standard interface that connects data in one process with code running in another process. In short content provider are more or less same like class any driver which we are normally using database connection. ● To read more about content provider please check link:http://developer. android.com/guide/topics/providers/content-provider-basics.html
  • 12. 2. Android Layouts ● ● ● ● A layout defines the visual structure for a user interface, such as the UI for an activity or app widget. You can declare a layout in two ways: Declare UI elements in XML. Android provides a straightforward XML vocabulary that corresponds to the View classes and subclasses, such as those for widgets and layouts. Instantiate layout elements at runtime. Your application can create View and ViewGroup objects (and manipulate their properties) programmatically Common Layout used in app design 1. Linear Layout 2. Relative Layout 3. List View 4. Grid View
  • 13. 2. Android Layouts 1. Linear Layout : To create linear layout we need to add below code in layout xml file.Using linear layout we can put other controls either vertically or horizontally which we can define by android:orientation attribute. <LinearLayout android:layout_width="fill_parent" android:layout_height="fill_parent" android:paddingLeft="16dp" android:paddingRight="16dp" android:orientation="vertical" ></LinearLayout >
  • 14. 2. Android Layouts 2.Relative Layout : is a view group that displays child views in relative positions. The position of each view can be specified as relative to sibling elements. <?xml version="1.0" encoding="utf-8"?> <RelativeLayout xmlns:android="http://schemas.android. com/apk/res/android" android:layout_width="fill_parent" android:layout_height="fill_parent" android:paddingLeft="16dp" android:paddingRight="16dp" > <EditText android:id="@+id/name" android:layout_width="fill_parent" android:layout_height="wrap_content" android:hint="@string/reminder" /> <Spinner android:id="@+id/dates" android:layout_width="0dp" android:layout_height="wrap_content" android:layout_below="@id/name" android:layout_alignParentLeft="true" android:layout_toLeftOf="@+id/times" /> <Spinner android:id="@id/times" android:layout_width="96dp" android:layout_height="wrap_content" android:layout_below="@id/name" android:layout_alignParentRight="true" /> <Button android:layout_width="96dp" android:layout_height="wrap_content" android:layout_below="@id/times" android:layout_alignParentRight="true" android:text="@string/done" />
  • 16. 2. Android Layout 3.Listview : ListView is a view group that displays a list of scrollable items. The list items are automatically inserted to the list using an Adapter that pulls content from a source such as an array or database query. ● Lets take an example of network list displayed where we have to display custom type of item.
  • 17. 2. Android Layout Mian Activty Layout screen <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" android:paddingBottom="@dimen/activity_vertical_margin" android:paddingLeft="@dimen/activity_horizontal_margin" android:paddingRight="@dimen/activity_horizontal_margin" android:paddingTop="@dimen/activity_vertical_margin" tools:context=".Network" > <ListView android:id="@+id/lvNetworkList" android:layout_width="match_parent" android:layout_height="match_parent" android:scrollbars="vertical" > </ListView> </RelativeLayout>
  • 18. 2. Android Layout List View Item Detail Desig <?xml version="1.0" encoding="utf-8"?> <RelativeLayout xmlns:android="http://schemas.android. com/apk/res/android" android:layout_width="match_parent" android:layout_height="fill_parent" > <TextView android:id="@+id/txtNetworkName" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignParentLeft="true" android:layout_alignParentTop="true" android:layout_marginLeft="20dp" android:layout_marginTop="22dp" android:text="@string/network_name" android:textAppearance="?android:attr/textAppearanceLarge" <TextView android:id="@+id/txtPortType" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignBaseline="@+id/txtNetworkType" android:layout_alignBottom="@+id/txtNetworkType" android:layout_alignParentRight="true" android:layout_marginRight="22dp" android:text="@string/port_type" android:textColor="#AAA" android:textAppearance="?android: attr/textAppearanceMedium" /> <TextView android:id="@+id/txtNetworkDscr" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignLeft="@+id/txtNetworkName" android:layout_alignRight="@+id/txtPortType" android:layout_below="@+id/txtNetworkName" android:text="@string/port_type" android:textColor="#AAA" android:textAppearance="?android:attr/textAppearanceSmall" /> <TextView android:id="@+id/txtNetworkType" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignLeft="@+id/txtNetworkName" android:layout_below="@+id/txtNetworkName" android:layout_marginTop="21dp" android:text="@string/network_type" android:textColor="#AAA" android:textAppearance="?android: attr/textAppearanceMedium" /> /> </RelativeLayout>
  • 19. 2. Android Layout Atcivity Code for Initialize listview LayoutInflater inflater = (LayoutInflater) context private ListView lvNetworkListCode = (ListView) findViewById(R.id. lvNetworkList); public ArrayList<NetworkModel> Networks = new ArrayList<NetworkModel>(); lvNetworkListCode.setAdapter(adapter); ItemAdapter adapter = new ItemAdapter(this,R.layout.network_item, Networks); ● Here NetworkModel is the model class have attributes of single item. ● ItemAdapter class is the important it has getView method which will iterate on models arraylist and print one byone item. private final Context context; private ArrayList<NetworkModel> Ids; private final int rowResourceId; public ItemAdapter(Context context, int resource, ArrayList<NetworkModel> objects) { super(context, resource, objects); this.context = context; this.Ids = objects; this.rowResourceId = resource; } .getSystemService(Context. LAYOUT_INFLATER_SERVICE); View rowView = inflater.inflate (rowResourceId, parent, false); txtNwNameCode = (TextView) rowView. findViewById(R.id.txtNetworkName); txtNwDscrCode = (TextView) rowView. findViewById(R.id.txtNetworkDscr); txtNwTypeCode = (TextView) rowView.findViewById(R.id. txtNetworkType); txtPortTypeCode = (TextView) rowView. findViewById(R.id.txtPortType); if (Ids.size() > 0) { // setting values from model txtNwNameCode.setText(Ids.get (position).getNetworkName()); txtNwDscrCode.setText(Ids.get (position).getNetworkDescr()); txtNwTypeCode.setText("N/W Type: "+Ids.get(position).getNetworkType()); txtPortTypeCode.setText("Port Type: "+Ids.get(position).getPortType()); @Override public View getView(int position, View convertView, ViewGroup parent) { } return rowView;
  • 20. 3. Basic UI Widgets ● ● In section we will see how to add basic UI controls like text-box,label, button and checkbox. Lets consider below UI if we wanted to design.
  • 21. 3. Basic UI Widgets Layout Design <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android. com/apk/res/android" android:layout_width="fill_parent" android:layout_height="fill_parent" android:orientation="vertical" > <TextView android:layout_width="fill_parent" android:layout_height="wrap_content" android:text="@string/enterNameLable" /> <EditText android:id="@+id/nameTxt" android:layout_width="fill_parent" android:layout_height="wrap_content" android:hint="@string/enterNameHint" /> <CheckBox android:id="@+id/appendHelloCheck" android:layout_width="fill_parent" android:layout_height="wrap_content" android:text="@string/appendHello" /> <RadioGroup android:id="@+id/radioGroup" android:layout_width="fill_parent" android:layout_height="wrap_content"> <RadioButton android:id="@+id/maleradio" android:layout_width="fill_parent" android:layout_height="wrap_content" android:text="@string/maleLbl"/> <RadioButton android:id="@+id/femaleradio" android:layout_width="fill_parent" android:layout_height="wrap_content" android:text="@string/femaleLbl" /> </RadioGroup> <Button android:id="@+id/showDataBtn" android:layout_width="fill_parent" android:layout_height="wrap_content" android:text="@string/okBtnTxt" /> <TextView android:id="@+id/resultText" android:layout_width="fill_parent" android:layout_height="wrap_content" /> <ImageView android:src="@drawable/maktabah" android:layout_width="fill_parent" android:layout_height="wrap_content" android:contentDescription="@+string/Image" /> </LinearLayout>
  • 22. 3. Basic UI Widgets Activity Code: OnClickListener showDataClickListener =new OnClickListener() { public class Tutorial1Activity extends Activity { @Override public void onClick(View v) { private Button showDataBtn; String userName = userNametxt.getText(). private EditText userNametxt; private CheckBox appendCheck; private RadioGroup maleFemaleRadioGroup; private TextView resultantText; /** Called when the activity is first created. */ @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.screen1); initViewCOntrols(); } public void initViewCOntrols() { userNametxt = (EditText) findViewById(R.id.nameTxt); appendCheck = (CheckBox) findViewById(R.id. appendHelloCheck); maleFemaleRadioGroup = (RadioGroup) findViewById(R.id. radioGroup); toString(); if(userName.length()>0){ RadioButton maleFRadio = (RadioButton) findViewById(maleFemaleRadioGroup. getCheckedRadioButtonId()); if(appendCheck.isChecked()){ resultantText.setText("Hello "+userName+" n You are"+maleFRadio.getText().toString()); }else { resultantText.setText (userName+" n You are"+maleFRadio.getText().toString()); } }else { userNametxt.setError("Please Enter Name."); } showDataBtn = (Button) findViewById(R.id.showDataBtn); resultantText = (TextView) findViewById(R.id.resultText); } }; showDataBtn.setOnClickListener(showDataClickListener); } }