SlideShare a Scribd company logo
1 of 15
Download to read offline
Mobile Application Development
(ITEC-303)
Fahim Abid
fahim.abid@uettaxila.edu.pk
fahim.abid@uoc.edu.pk
Credits Hours 3(3,0)
Recommended Books
1. Professional Android application development, Reto Meier, Wrox Programmer to
Programmer, 2015.
2. Android Programming: The Big Nerd Ranch Guides, Phillips, B. & Hardy, B., 2nd
Edition, 2014.
3. iOS Programming: The Big Nerd Ranch Guide, Conway, J., Hillegass, A., & Keur, C.,
5th Edition, 2014.
What is Intents
Intents are used as a message-passing mechanism that works both within your
application and between applications.
An Intent in the Android operating system is a software mechanism that allows users
to coordinate the functions of different activities to achieve a task.
One of the most common uses for Intents is to start new Activities, either explicitly
(by specifying the class to load) or implicitly (by requesting an action be performed
on a piece of data).
Intents can also be used to broadcast messages across the system. Any application
can register a Broadcast Receiver to listen for, and react to, these broadcast Intents.
This lets you create event-driven applications based on internal, system, or third-
party application events.
Intents You can use Intents to do the following:
 Explicitly start a particular Service or Activity using its class name.
 Start an Activity or Service to perform an action with (or on) a particular piece of
data.
 Broadcast that an event has occurred.
Using Intents to Launch Activities
The most common use of Intents is to bind your application components. Intents are
used to start, stop and transition between the Activities within an application.
To open a different application screen (Activity) in your application, call startActivity,
passing in an Intent, as shown in below.
startActivity(myIntent);
The Intent can either explicitly specify the class to open or include an action that the
target should perform. In the latter case, the run time will choose the Activity to
open, using a process known as “Intent resolution.”
The startActivity method finds and starts the single Activity that best matches your
Intent.
When using startActivity, your application won’t receive any notification when the
newly launched Activity finishes.
To explicitly select an Activity class to start, create a new Intent specifying the
current application context and the class of the Activity to launch. Pass this Intent in
to startActivity, as shown in below:
Intent intent = new Intent(MyActivity.this, MyOtherActivity.class);
startActivity(intent);
After calling startActivity, the new Activity (in this example, MyOtherActivity) will be
created and become visible and active, moving to the top of the Activity stack.
Calling finish programmatically on the new Activity will close it and remove it from
the stack. Alternatively, users can navigate to the previous Activity using the device’s
Back button.
What is Adapters
Adapters are bridging classes that bind data to user-interface Views. The adapter is
responsible for creating the child views used to represent each item and providing
access to the underlying data.
User-interface controls that support Adapter binding must extend the AdapterView
abstract class. It’s possible to create your own AdapterView-derived controls and
create new Adapter classes to bind them.
Adapters are responsible both for supplying the data and selecting the Views that
represent each item, Adaptors can radically modify the appearance and functionality
of the controls they’re bound to.
The following list highlights two of the most useful and versatile native adapters:
 ArrayAdapter: The ArrayAdapter is a generic class that binds Adapter Views to an
array of objects. By default, the ArrayAdapter binds the toString value of each
object to a TextView control defined within a layout.
 SimpleCursorAdapter: The SimpleCursorAdapter binds Views to cursors returned
from Content Provider queries.
You specify an XML layout definition and then bind the value within each column in
the result set, to a View in that layout.
Using Adapters for Data Binding
To apply an Adapter to an AdapterView-derived class, you call the View’s setAdapter
method, passing in an Adapter instance, as shown in below:
ArrayList<String> myStringArray = new ArrayList<String>();
ArrayAdapter<String> myAdapterInstance;
int layoutID = android.R.layout.simple_list_item_1;
myAdapterInstance = new ArrayAdapter<String>(this, layoutID, myStringArray);
myListView.setAdapter(myAdapterInstance);
This snippet shows the most simplistic case, where the array being bound is a string
and the List View items are displayed using a single Text View control.
Using Internet Resources
With Internet connectivity and WebKit browser, you might well ask if there’s any
reason to create native Internet-based applications when you could make a web-
based version instead.
There are several benefits to creating thick- and thin-client native applications rather
than relying on entirely web-based solutions:
 Bandwidth Static resources like images, layouts, and sounds can be expensive
data consumers on devices with limited and often expensive bandwidth
restraints. By creating a native application, you can limit the bandwidth
requirements to only data updates.
 Caching Mobile Internet access has not yet reached the point of ubiquity. With a
browser based solution, a patchy Internet connection can result in intermittent
application availability. A native application can cache data to provide as much
functionality as possible without a live connection.
 Native Features Android devices are more than a simple platform for running a
browser; they include location-based services, camera hardware, and
accelerometers. By creating a native application, you can combine the data
available online with the hardware features available on the device to provide a
richer user experience.
Modern mobile devices offer various alternatives for accessing the Internet. Looked
at broadly, Android provides three connection techniques for Internet connectivity.
Each is offered transparently to the application layer.
 GPRS, EDGE, and 3G Mobile Internet access is available through carriers that offer
mobile data plans.
 Wi-Fi: Wi-Fi receivers and mobile hotspots are becoming increasingly more
common.
Connecting to an Internet Resource
you can access Internet resources, you need to add an INTERNET uses-permission
node to your application manifest, as shown in the following XML snippet:
<uses-permission android:name=”android.permission.INTERNET”/>
The following skeleton code shows the basic pattern for opening an Internet data stream:
String myFeed = getString(R.string.my_feed);
try {
URL url = new URL(myFeed);
URLConnection connection = url.openConnection();
HttpURLConnection httpConnection = (HttpURLConnection)connection;
int responseCode = httpConnection.getResponseCode();
if (responseCode == HttpURLConnection.HTTP_OK) {
InputStream in = httpConnection.getInputStream();
[ ... Process the input stream as required ... ]
}
}
catch (MalformedURLException e) { }
catch (IOException e) { }
What is Dialogs
Dialog boxes are a common UI metaphor in desktop and web applications. They’re
used to help users answer questions, make selections, confirm actions, and read
warning or error messages. An Android Dialog is a floating window that partially
obscures the Activity that launched it.
There are three ways to implement a Dialog box in Android:
 Using a Dialog-Class Descendent: As well as the general-purpose AlertDialog
class, Android includes several specialist classes that extend Dialog. Each is
designed to provide specific Dialog-box functionality. Dialog-class-based screens
are constructed entirely within their calling Activity, so they don’t need to be
registered in the manifest, and their life cycle is controlled entirely by the calling
Activity.
 Dialog-Themed Activities: You can apply the Dialog theme to a regular Activity to
give it the appearance of a Dialog box.
 Toasts: Toasts are special non-modal transient message boxes, often used by
Broadcast Receivers and background services to notify users of events.
Creating an Earthquake Viewer
Page. No. 172 of Professional Android Application Development
In this example you’ll create a list-based Activity that connects to an earthquake feed
and displays the location, magnitude, and time of the earthquakes it contains.
1. Start by creating an Earthquake project featuring an Earthquake Activity.
2. Create a new EarthquakeListFragment that extends ListFragment. This Fragment
displays your list of earthquakes.
public class EarthquakeListFragment extends ListFragment {
}
3. Modify the main.xml layout resource to include the Fragment you created in Step
Be sure to name it so that you can reference it from the Activity code.

More Related Content

Similar to Mobile Application Development -Lecture 09 & 10.pdf

Nativa Android Applications development
Nativa Android Applications developmentNativa Android Applications development
Nativa Android Applications developmentAlfredo Morresi
 
Android tutorial
Android tutorialAndroid tutorial
Android tutorialAbid Khan
 
Android interview questions and answers
Android interview questions and answersAndroid interview questions and answers
Android interview questions and answerskavinilavuG
 
Mobile Application Development Lecture 05 & 06.pdf
Mobile Application Development Lecture 05 & 06.pdfMobile Application Development Lecture 05 & 06.pdf
Mobile Application Development Lecture 05 & 06.pdfAbdullahMunir32
 
Android application development
Android application developmentAndroid application development
Android application developmentMd. Mujahid Islam
 
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
 
Android terminologies
Android terminologiesAndroid terminologies
Android terminologiesjerry vasoya
 
Introduction to Android Development
Introduction to Android DevelopmentIntroduction to Android Development
Introduction to Android DevelopmentProf. Erwin Globio
 
Using intents in android
Using intents in androidUsing intents in android
Using intents in androidOum Saokosal
 
DEVELOPING CUSTOM APPS USING DYNAMIC XML PARSING
DEVELOPING CUSTOM APPS USING DYNAMIC XML PARSINGDEVELOPING CUSTOM APPS USING DYNAMIC XML PARSING
DEVELOPING CUSTOM APPS USING DYNAMIC XML PARSINGJournal For Research
 
Location sharing and automatic message sender Android Application
Location sharing and automatic message sender Android ApplicationLocation sharing and automatic message sender Android Application
Location sharing and automatic message sender Android ApplicationKavita Sharma
 
Android Bootcamp Tanzania:understanding ui in_android
Android Bootcamp Tanzania:understanding ui in_androidAndroid Bootcamp Tanzania:understanding ui in_android
Android Bootcamp Tanzania:understanding ui in_androidDenis Minja
 
Android building blocks and application life cycle-chapter3
Android building blocks and application life cycle-chapter3Android building blocks and application life cycle-chapter3
Android building blocks and application life cycle-chapter3Dr. Ramkumar Lakshminarayanan
 

Similar to Mobile Application Development -Lecture 09 & 10.pdf (20)

Nativa Android Applications development
Nativa Android Applications developmentNativa Android Applications development
Nativa Android Applications development
 
Android tutorial
Android tutorialAndroid tutorial
Android tutorial
 
Android Basic- CMC
Android Basic- CMCAndroid Basic- CMC
Android Basic- CMC
 
ANDROID
ANDROIDANDROID
ANDROID
 
Dm36678681
Dm36678681Dm36678681
Dm36678681
 
Ppt 2 android_basics
Ppt 2 android_basicsPpt 2 android_basics
Ppt 2 android_basics
 
Android interview questions and answers
Android interview questions and answersAndroid interview questions and answers
Android interview questions and answers
 
Android beginners David
Android beginners DavidAndroid beginners David
Android beginners David
 
Mobile testing android
Mobile testing   androidMobile testing   android
Mobile testing android
 
Android TCJUG
Android TCJUGAndroid TCJUG
Android TCJUG
 
Mobile Application Development Lecture 05 & 06.pdf
Mobile Application Development Lecture 05 & 06.pdfMobile Application Development Lecture 05 & 06.pdf
Mobile Application Development Lecture 05 & 06.pdf
 
Android application development
Android application developmentAndroid application development
Android application development
 
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
 
Android terminologies
Android terminologiesAndroid terminologies
Android terminologies
 
Introduction to Android Development
Introduction to Android DevelopmentIntroduction to Android Development
Introduction to Android Development
 
Using intents in android
Using intents in androidUsing intents in android
Using intents in android
 
DEVELOPING CUSTOM APPS USING DYNAMIC XML PARSING
DEVELOPING CUSTOM APPS USING DYNAMIC XML PARSINGDEVELOPING CUSTOM APPS USING DYNAMIC XML PARSING
DEVELOPING CUSTOM APPS USING DYNAMIC XML PARSING
 
Location sharing and automatic message sender Android Application
Location sharing and automatic message sender Android ApplicationLocation sharing and automatic message sender Android Application
Location sharing and automatic message sender Android Application
 
Android Bootcamp Tanzania:understanding ui in_android
Android Bootcamp Tanzania:understanding ui in_androidAndroid Bootcamp Tanzania:understanding ui in_android
Android Bootcamp Tanzania:understanding ui in_android
 
Android building blocks and application life cycle-chapter3
Android building blocks and application life cycle-chapter3Android building blocks and application life cycle-chapter3
Android building blocks and application life cycle-chapter3
 

More from AbdullahMunir32

Mobile Application Development-Lecture 15 & 16.pdf
Mobile Application Development-Lecture 15 & 16.pdfMobile Application Development-Lecture 15 & 16.pdf
Mobile Application Development-Lecture 15 & 16.pdfAbdullahMunir32
 
Mobile Application Development-Lecture 13 & 14.pdf
Mobile Application Development-Lecture 13 & 14.pdfMobile Application Development-Lecture 13 & 14.pdf
Mobile Application Development-Lecture 13 & 14.pdfAbdullahMunir32
 
Mobile Application Development -Lecture 11 & 12.pdf
Mobile Application Development -Lecture 11 & 12.pdfMobile Application Development -Lecture 11 & 12.pdf
Mobile Application Development -Lecture 11 & 12.pdfAbdullahMunir32
 
Mobile Application Development -Lecture 07 & 08.pdf
Mobile Application Development -Lecture 07 & 08.pdfMobile Application Development -Lecture 07 & 08.pdf
Mobile Application Development -Lecture 07 & 08.pdfAbdullahMunir32
 
Mobile Application Development-Lecture 03 & 04.pdf
Mobile Application Development-Lecture 03 & 04.pdfMobile Application Development-Lecture 03 & 04.pdf
Mobile Application Development-Lecture 03 & 04.pdfAbdullahMunir32
 
Mobile Application Development-Lecture 01 & 02.pdf
Mobile Application Development-Lecture 01 & 02.pdfMobile Application Development-Lecture 01 & 02.pdf
Mobile Application Development-Lecture 01 & 02.pdfAbdullahMunir32
 
Parallel and Distributed Computing Chapter 13
Parallel and Distributed Computing Chapter 13Parallel and Distributed Computing Chapter 13
Parallel and Distributed Computing Chapter 13AbdullahMunir32
 
Parallel and Distributed Computing Chapter 12
Parallel and Distributed Computing Chapter 12Parallel and Distributed Computing Chapter 12
Parallel and Distributed Computing Chapter 12AbdullahMunir32
 
Parallel and Distributed Computing Chapter 11
Parallel and Distributed Computing Chapter 11Parallel and Distributed Computing Chapter 11
Parallel and Distributed Computing Chapter 11AbdullahMunir32
 
Parallel and Distributed Computing Chapter 10
Parallel and Distributed Computing Chapter 10Parallel and Distributed Computing Chapter 10
Parallel and Distributed Computing Chapter 10AbdullahMunir32
 
Parallel and Distributed Computing Chapter 9
Parallel and Distributed Computing Chapter 9Parallel and Distributed Computing Chapter 9
Parallel and Distributed Computing Chapter 9AbdullahMunir32
 
Parallel and Distributed Computing Chapter 8
Parallel and Distributed Computing Chapter 8Parallel and Distributed Computing Chapter 8
Parallel and Distributed Computing Chapter 8AbdullahMunir32
 
Parallel and Distributed Computing Chapter 7
Parallel and Distributed Computing Chapter 7Parallel and Distributed Computing Chapter 7
Parallel and Distributed Computing Chapter 7AbdullahMunir32
 
Parallel and Distributed Computing Chapter 6
Parallel and Distributed Computing Chapter 6Parallel and Distributed Computing Chapter 6
Parallel and Distributed Computing Chapter 6AbdullahMunir32
 
Parallel and Distributed Computing Chapter 5
Parallel and Distributed Computing Chapter 5Parallel and Distributed Computing Chapter 5
Parallel and Distributed Computing Chapter 5AbdullahMunir32
 
Parallel and Distributed Computing Chapter 4
Parallel and Distributed Computing Chapter 4Parallel and Distributed Computing Chapter 4
Parallel and Distributed Computing Chapter 4AbdullahMunir32
 
Parallel and Distributed Computing chapter 3
Parallel and Distributed Computing chapter 3Parallel and Distributed Computing chapter 3
Parallel and Distributed Computing chapter 3AbdullahMunir32
 
Parallel and Distributed Computing Chapter 2
Parallel and Distributed Computing Chapter 2Parallel and Distributed Computing Chapter 2
Parallel and Distributed Computing Chapter 2AbdullahMunir32
 
Parallel and Distributed Computing chapter 1
Parallel and Distributed Computing chapter 1Parallel and Distributed Computing chapter 1
Parallel and Distributed Computing chapter 1AbdullahMunir32
 

More from AbdullahMunir32 (19)

Mobile Application Development-Lecture 15 & 16.pdf
Mobile Application Development-Lecture 15 & 16.pdfMobile Application Development-Lecture 15 & 16.pdf
Mobile Application Development-Lecture 15 & 16.pdf
 
Mobile Application Development-Lecture 13 & 14.pdf
Mobile Application Development-Lecture 13 & 14.pdfMobile Application Development-Lecture 13 & 14.pdf
Mobile Application Development-Lecture 13 & 14.pdf
 
Mobile Application Development -Lecture 11 & 12.pdf
Mobile Application Development -Lecture 11 & 12.pdfMobile Application Development -Lecture 11 & 12.pdf
Mobile Application Development -Lecture 11 & 12.pdf
 
Mobile Application Development -Lecture 07 & 08.pdf
Mobile Application Development -Lecture 07 & 08.pdfMobile Application Development -Lecture 07 & 08.pdf
Mobile Application Development -Lecture 07 & 08.pdf
 
Mobile Application Development-Lecture 03 & 04.pdf
Mobile Application Development-Lecture 03 & 04.pdfMobile Application Development-Lecture 03 & 04.pdf
Mobile Application Development-Lecture 03 & 04.pdf
 
Mobile Application Development-Lecture 01 & 02.pdf
Mobile Application Development-Lecture 01 & 02.pdfMobile Application Development-Lecture 01 & 02.pdf
Mobile Application Development-Lecture 01 & 02.pdf
 
Parallel and Distributed Computing Chapter 13
Parallel and Distributed Computing Chapter 13Parallel and Distributed Computing Chapter 13
Parallel and Distributed Computing Chapter 13
 
Parallel and Distributed Computing Chapter 12
Parallel and Distributed Computing Chapter 12Parallel and Distributed Computing Chapter 12
Parallel and Distributed Computing Chapter 12
 
Parallel and Distributed Computing Chapter 11
Parallel and Distributed Computing Chapter 11Parallel and Distributed Computing Chapter 11
Parallel and Distributed Computing Chapter 11
 
Parallel and Distributed Computing Chapter 10
Parallel and Distributed Computing Chapter 10Parallel and Distributed Computing Chapter 10
Parallel and Distributed Computing Chapter 10
 
Parallel and Distributed Computing Chapter 9
Parallel and Distributed Computing Chapter 9Parallel and Distributed Computing Chapter 9
Parallel and Distributed Computing Chapter 9
 
Parallel and Distributed Computing Chapter 8
Parallel and Distributed Computing Chapter 8Parallel and Distributed Computing Chapter 8
Parallel and Distributed Computing Chapter 8
 
Parallel and Distributed Computing Chapter 7
Parallel and Distributed Computing Chapter 7Parallel and Distributed Computing Chapter 7
Parallel and Distributed Computing Chapter 7
 
Parallel and Distributed Computing Chapter 6
Parallel and Distributed Computing Chapter 6Parallel and Distributed Computing Chapter 6
Parallel and Distributed Computing Chapter 6
 
Parallel and Distributed Computing Chapter 5
Parallel and Distributed Computing Chapter 5Parallel and Distributed Computing Chapter 5
Parallel and Distributed Computing Chapter 5
 
Parallel and Distributed Computing Chapter 4
Parallel and Distributed Computing Chapter 4Parallel and Distributed Computing Chapter 4
Parallel and Distributed Computing Chapter 4
 
Parallel and Distributed Computing chapter 3
Parallel and Distributed Computing chapter 3Parallel and Distributed Computing chapter 3
Parallel and Distributed Computing chapter 3
 
Parallel and Distributed Computing Chapter 2
Parallel and Distributed Computing Chapter 2Parallel and Distributed Computing Chapter 2
Parallel and Distributed Computing Chapter 2
 
Parallel and Distributed Computing chapter 1
Parallel and Distributed Computing chapter 1Parallel and Distributed Computing chapter 1
Parallel and Distributed Computing chapter 1
 

Recently uploaded

Meghan Sutherland In Media Res Media Component
Meghan Sutherland In Media Res Media ComponentMeghan Sutherland In Media Res Media Component
Meghan Sutherland In Media Res Media ComponentInMediaRes1
 
Alper Gobel In Media Res Media Component
Alper Gobel In Media Res Media ComponentAlper Gobel In Media Res Media Component
Alper Gobel In Media Res Media ComponentInMediaRes1
 
Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)eniolaolutunde
 
Crayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon ACrayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon AUnboundStockton
 
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions  for the students and aspirants of Chemistry12th.pptxOrganic Name Reactions  for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions for the students and aspirants of Chemistry12th.pptxVS Mahajan Coaching Centre
 
Hierarchy of management that covers different levels of management
Hierarchy of management that covers different levels of managementHierarchy of management that covers different levels of management
Hierarchy of management that covers different levels of managementmkooblal
 
KSHARA STURA .pptx---KSHARA KARMA THERAPY (CAUSTIC THERAPY)————IMP.OF KSHARA ...
KSHARA STURA .pptx---KSHARA KARMA THERAPY (CAUSTIC THERAPY)————IMP.OF KSHARA ...KSHARA STURA .pptx---KSHARA KARMA THERAPY (CAUSTIC THERAPY)————IMP.OF KSHARA ...
KSHARA STURA .pptx---KSHARA KARMA THERAPY (CAUSTIC THERAPY)————IMP.OF KSHARA ...M56BOOKSTORE PRODUCT/SERVICE
 
Capitol Tech U Doctoral Presentation - April 2024.pptx
Capitol Tech U Doctoral Presentation - April 2024.pptxCapitol Tech U Doctoral Presentation - April 2024.pptx
Capitol Tech U Doctoral Presentation - April 2024.pptxCapitolTechU
 
Framing an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdf
Framing an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdfFraming an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdf
Framing an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdfUjwalaBharambe
 
Earth Day Presentation wow hello nice great
Earth Day Presentation wow hello nice greatEarth Day Presentation wow hello nice great
Earth Day Presentation wow hello nice greatYousafMalik24
 
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️9953056974 Low Rate Call Girls In Saket, Delhi NCR
 
Full Stack Web Development Course for Beginners
Full Stack Web Development Course  for BeginnersFull Stack Web Development Course  for Beginners
Full Stack Web Development Course for BeginnersSabitha Banu
 
Types of Journalistic Writing Grade 8.pptx
Types of Journalistic Writing Grade 8.pptxTypes of Journalistic Writing Grade 8.pptx
Types of Journalistic Writing Grade 8.pptxEyham Joco
 
DATA STRUCTURE AND ALGORITHM for beginners
DATA STRUCTURE AND ALGORITHM for beginnersDATA STRUCTURE AND ALGORITHM for beginners
DATA STRUCTURE AND ALGORITHM for beginnersSabitha Banu
 
Presiding Officer Training module 2024 lok sabha elections
Presiding Officer Training module 2024 lok sabha electionsPresiding Officer Training module 2024 lok sabha elections
Presiding Officer Training module 2024 lok sabha electionsanshu789521
 
EPANDING THE CONTENT OF AN OUTLINE using notes.pptx
EPANDING THE CONTENT OF AN OUTLINE using notes.pptxEPANDING THE CONTENT OF AN OUTLINE using notes.pptx
EPANDING THE CONTENT OF AN OUTLINE using notes.pptxRaymartEstabillo3
 
भारत-रोम व्यापार.pptx, Indo-Roman Trade,
भारत-रोम व्यापार.pptx, Indo-Roman Trade,भारत-रोम व्यापार.pptx, Indo-Roman Trade,
भारत-रोम व्यापार.pptx, Indo-Roman Trade,Virag Sontakke
 

Recently uploaded (20)

Meghan Sutherland In Media Res Media Component
Meghan Sutherland In Media Res Media ComponentMeghan Sutherland In Media Res Media Component
Meghan Sutherland In Media Res Media Component
 
Alper Gobel In Media Res Media Component
Alper Gobel In Media Res Media ComponentAlper Gobel In Media Res Media Component
Alper Gobel In Media Res Media Component
 
TataKelola dan KamSiber Kecerdasan Buatan v022.pdf
TataKelola dan KamSiber Kecerdasan Buatan v022.pdfTataKelola dan KamSiber Kecerdasan Buatan v022.pdf
TataKelola dan KamSiber Kecerdasan Buatan v022.pdf
 
Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)
 
Crayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon ACrayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon A
 
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions  for the students and aspirants of Chemistry12th.pptxOrganic Name Reactions  for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
 
Hierarchy of management that covers different levels of management
Hierarchy of management that covers different levels of managementHierarchy of management that covers different levels of management
Hierarchy of management that covers different levels of management
 
KSHARA STURA .pptx---KSHARA KARMA THERAPY (CAUSTIC THERAPY)————IMP.OF KSHARA ...
KSHARA STURA .pptx---KSHARA KARMA THERAPY (CAUSTIC THERAPY)————IMP.OF KSHARA ...KSHARA STURA .pptx---KSHARA KARMA THERAPY (CAUSTIC THERAPY)————IMP.OF KSHARA ...
KSHARA STURA .pptx---KSHARA KARMA THERAPY (CAUSTIC THERAPY)————IMP.OF KSHARA ...
 
Capitol Tech U Doctoral Presentation - April 2024.pptx
Capitol Tech U Doctoral Presentation - April 2024.pptxCapitol Tech U Doctoral Presentation - April 2024.pptx
Capitol Tech U Doctoral Presentation - April 2024.pptx
 
Framing an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdf
Framing an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdfFraming an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdf
Framing an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdf
 
Earth Day Presentation wow hello nice great
Earth Day Presentation wow hello nice greatEarth Day Presentation wow hello nice great
Earth Day Presentation wow hello nice great
 
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
 
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
 
Full Stack Web Development Course for Beginners
Full Stack Web Development Course  for BeginnersFull Stack Web Development Course  for Beginners
Full Stack Web Development Course for Beginners
 
Types of Journalistic Writing Grade 8.pptx
Types of Journalistic Writing Grade 8.pptxTypes of Journalistic Writing Grade 8.pptx
Types of Journalistic Writing Grade 8.pptx
 
DATA STRUCTURE AND ALGORITHM for beginners
DATA STRUCTURE AND ALGORITHM for beginnersDATA STRUCTURE AND ALGORITHM for beginners
DATA STRUCTURE AND ALGORITHM for beginners
 
OS-operating systems- ch04 (Threads) ...
OS-operating systems- ch04 (Threads) ...OS-operating systems- ch04 (Threads) ...
OS-operating systems- ch04 (Threads) ...
 
Presiding Officer Training module 2024 lok sabha elections
Presiding Officer Training module 2024 lok sabha electionsPresiding Officer Training module 2024 lok sabha elections
Presiding Officer Training module 2024 lok sabha elections
 
EPANDING THE CONTENT OF AN OUTLINE using notes.pptx
EPANDING THE CONTENT OF AN OUTLINE using notes.pptxEPANDING THE CONTENT OF AN OUTLINE using notes.pptx
EPANDING THE CONTENT OF AN OUTLINE using notes.pptx
 
भारत-रोम व्यापार.pptx, Indo-Roman Trade,
भारत-रोम व्यापार.pptx, Indo-Roman Trade,भारत-रोम व्यापार.pptx, Indo-Roman Trade,
भारत-रोम व्यापार.pptx, Indo-Roman Trade,
 

Mobile Application Development -Lecture 09 & 10.pdf

  • 1. Mobile Application Development (ITEC-303) Fahim Abid fahim.abid@uettaxila.edu.pk fahim.abid@uoc.edu.pk
  • 2. Credits Hours 3(3,0) Recommended Books 1. Professional Android application development, Reto Meier, Wrox Programmer to Programmer, 2015. 2. Android Programming: The Big Nerd Ranch Guides, Phillips, B. & Hardy, B., 2nd Edition, 2014. 3. iOS Programming: The Big Nerd Ranch Guide, Conway, J., Hillegass, A., & Keur, C., 5th Edition, 2014.
  • 3. What is Intents Intents are used as a message-passing mechanism that works both within your application and between applications. An Intent in the Android operating system is a software mechanism that allows users to coordinate the functions of different activities to achieve a task. One of the most common uses for Intents is to start new Activities, either explicitly (by specifying the class to load) or implicitly (by requesting an action be performed on a piece of data). Intents can also be used to broadcast messages across the system. Any application can register a Broadcast Receiver to listen for, and react to, these broadcast Intents. This lets you create event-driven applications based on internal, system, or third- party application events.
  • 4. Intents You can use Intents to do the following:  Explicitly start a particular Service or Activity using its class name.  Start an Activity or Service to perform an action with (or on) a particular piece of data.  Broadcast that an event has occurred. Using Intents to Launch Activities The most common use of Intents is to bind your application components. Intents are used to start, stop and transition between the Activities within an application.
  • 5. To open a different application screen (Activity) in your application, call startActivity, passing in an Intent, as shown in below. startActivity(myIntent); The Intent can either explicitly specify the class to open or include an action that the target should perform. In the latter case, the run time will choose the Activity to open, using a process known as “Intent resolution.” The startActivity method finds and starts the single Activity that best matches your Intent. When using startActivity, your application won’t receive any notification when the newly launched Activity finishes.
  • 6. To explicitly select an Activity class to start, create a new Intent specifying the current application context and the class of the Activity to launch. Pass this Intent in to startActivity, as shown in below: Intent intent = new Intent(MyActivity.this, MyOtherActivity.class); startActivity(intent); After calling startActivity, the new Activity (in this example, MyOtherActivity) will be created and become visible and active, moving to the top of the Activity stack. Calling finish programmatically on the new Activity will close it and remove it from the stack. Alternatively, users can navigate to the previous Activity using the device’s Back button.
  • 7. What is Adapters Adapters are bridging classes that bind data to user-interface Views. The adapter is responsible for creating the child views used to represent each item and providing access to the underlying data. User-interface controls that support Adapter binding must extend the AdapterView abstract class. It’s possible to create your own AdapterView-derived controls and create new Adapter classes to bind them. Adapters are responsible both for supplying the data and selecting the Views that represent each item, Adaptors can radically modify the appearance and functionality of the controls they’re bound to. The following list highlights two of the most useful and versatile native adapters:
  • 8.  ArrayAdapter: The ArrayAdapter is a generic class that binds Adapter Views to an array of objects. By default, the ArrayAdapter binds the toString value of each object to a TextView control defined within a layout.  SimpleCursorAdapter: The SimpleCursorAdapter binds Views to cursors returned from Content Provider queries. You specify an XML layout definition and then bind the value within each column in the result set, to a View in that layout. Using Adapters for Data Binding To apply an Adapter to an AdapterView-derived class, you call the View’s setAdapter method, passing in an Adapter instance, as shown in below:
  • 9. ArrayList<String> myStringArray = new ArrayList<String>(); ArrayAdapter<String> myAdapterInstance; int layoutID = android.R.layout.simple_list_item_1; myAdapterInstance = new ArrayAdapter<String>(this, layoutID, myStringArray); myListView.setAdapter(myAdapterInstance); This snippet shows the most simplistic case, where the array being bound is a string and the List View items are displayed using a single Text View control.
  • 10. Using Internet Resources With Internet connectivity and WebKit browser, you might well ask if there’s any reason to create native Internet-based applications when you could make a web- based version instead. There are several benefits to creating thick- and thin-client native applications rather than relying on entirely web-based solutions:  Bandwidth Static resources like images, layouts, and sounds can be expensive data consumers on devices with limited and often expensive bandwidth restraints. By creating a native application, you can limit the bandwidth requirements to only data updates.  Caching Mobile Internet access has not yet reached the point of ubiquity. With a browser based solution, a patchy Internet connection can result in intermittent application availability. A native application can cache data to provide as much functionality as possible without a live connection.
  • 11.  Native Features Android devices are more than a simple platform for running a browser; they include location-based services, camera hardware, and accelerometers. By creating a native application, you can combine the data available online with the hardware features available on the device to provide a richer user experience. Modern mobile devices offer various alternatives for accessing the Internet. Looked at broadly, Android provides three connection techniques for Internet connectivity. Each is offered transparently to the application layer.  GPRS, EDGE, and 3G Mobile Internet access is available through carriers that offer mobile data plans.  Wi-Fi: Wi-Fi receivers and mobile hotspots are becoming increasingly more common.
  • 12. Connecting to an Internet Resource you can access Internet resources, you need to add an INTERNET uses-permission node to your application manifest, as shown in the following XML snippet: <uses-permission android:name=”android.permission.INTERNET”/> The following skeleton code shows the basic pattern for opening an Internet data stream: String myFeed = getString(R.string.my_feed); try { URL url = new URL(myFeed); URLConnection connection = url.openConnection(); HttpURLConnection httpConnection = (HttpURLConnection)connection; int responseCode = httpConnection.getResponseCode(); if (responseCode == HttpURLConnection.HTTP_OK) { InputStream in = httpConnection.getInputStream(); [ ... Process the input stream as required ... ] } } catch (MalformedURLException e) { } catch (IOException e) { }
  • 13. What is Dialogs Dialog boxes are a common UI metaphor in desktop and web applications. They’re used to help users answer questions, make selections, confirm actions, and read warning or error messages. An Android Dialog is a floating window that partially obscures the Activity that launched it.
  • 14. There are three ways to implement a Dialog box in Android:  Using a Dialog-Class Descendent: As well as the general-purpose AlertDialog class, Android includes several specialist classes that extend Dialog. Each is designed to provide specific Dialog-box functionality. Dialog-class-based screens are constructed entirely within their calling Activity, so they don’t need to be registered in the manifest, and their life cycle is controlled entirely by the calling Activity.  Dialog-Themed Activities: You can apply the Dialog theme to a regular Activity to give it the appearance of a Dialog box.  Toasts: Toasts are special non-modal transient message boxes, often used by Broadcast Receivers and background services to notify users of events.
  • 15. Creating an Earthquake Viewer Page. No. 172 of Professional Android Application Development In this example you’ll create a list-based Activity that connects to an earthquake feed and displays the location, magnitude, and time of the earthquakes it contains. 1. Start by creating an Earthquake project featuring an Earthquake Activity. 2. Create a new EarthquakeListFragment that extends ListFragment. This Fragment displays your list of earthquakes. public class EarthquakeListFragment extends ListFragment { } 3. Modify the main.xml layout resource to include the Fragment you created in Step Be sure to name it so that you can reference it from the Activity code.