Module 01 Mobile Application Development
Module 01 Mobile Application Development
• Gaming apps: The equivalent of computer video games, they are among
the most popular types of apps.
• Productivity apps: These focus on improving business efficiency by easing
various tasks such as sending emails, tracking work progress, booking hotels,
and much more.
• Lifestyle and entertainment apps: Increasingly popular, these encompass
many aspects of personal lifestyle and socialization such as communicating
on social media, as well as sharing (and watching) videos. Some of the most
widely known apps such as Netflix, Facebook fall into this category.
1982: First Generation (1G — analog voice only) systems with large heavy
phones and poor network quality were introduced.
4) 2G(Second Generation):
o 1992: Second Generation (2G) was deployed with improvements in signaling and
hardware that were primarily aimed toward the voice market but, unlike the first-
generation systems, used digital modulation to enhance call quality and enable
new applications such as Short Messaging Services (SMS) and other low-data-
rate (9.6 to 237 kbps) wireless applications.
5) 3G (Third Generation):
o 3G stands for third-generation access technology, which allows mobile phones
to connect to the internet.
o Every new technology introduces new frequency bands and data transmission
rates.
o The development of 3G connection-based networks in 2001 marked the start
of mainstream Internet use on mobile phones.
o Soon after, smartphones were introduced, bringing all of the capabilities of a
device into the palm of your hand.
o The signals are transmitted by a network of telephone towers. The user’s
mobile phone is receiving data from the tower nearest to it.
o 3G technology was revolutionary at the time it was introduced.
o 3G systems are intended for digital phones with a full-screen display and better
connectivity.
6) 4G:
o The fourth generation of mobile networking technology is known as 4G,
which comes after the 2G and 3G networks.
o Although it’s commonly referred to as 4G LTE.
o Most mobile network service providers use it now since it is the most
developed technology.
o When it initially came out, 4G revolutionized how we use the mobile internet.
o 4G network connectivity allowed consumers to browse the internet and
watch HD films on their mobile devices, thereby turning smartphones into
laptops.
o However, as you may have heard, 5G is becoming operational alongside
current 3G and 4G mobile networks.
o Most tasks that you can do on a laptop or desktop computer can now be
done on mobile devices such as smartphones or tablets. No matter how
much data you require, 4 G networks allow you to keep consistent speeds
practically anywhere. 4G was launched in the United Kingdom in 2012.
o Expect this to alter in the coming years as 4G contracts become more
affordable and 4G network coverage increases across the UK.
o Download speed ang Uploading data is also significantly faster.
5. Global System for Mobile technology:
o The (GSM) is an acronym for Global System for Mobile Communication.
o GSM is a cellular technology that is open and digital and is used for mobile
communication.
6. Code Division Multiple Access:
o The (CDMA) is an acronym for code division multiple access.
o It is a channel access mechanism that also serves as an example of multiple
access. Multiple access simply means that data from multiple transmitters can
be delivered onto a single communication channel at the same time.
7. Wi-Fi (Wireless Fidelity):
o Wi-Fi is a wireless networking technology that allows us to connect to a
network or to other computers or mobile devices across a wireless channel.
o wireless network that functions as a Local Area Network without the use of
cables or other types of cabling.
There are following four main components that can be used within an Android
application −
Components & Description
Activities
1 They dictate the UI and handle the user interaction to the smart
phone screen.
Services
2
They handle background processing associated with an application.
Broadcast Receivers
3
They handle communication between Android OS and applications.
Content Providers
4
They handle data and database management issues.
Activities
Fragments
1
Represents a portion of user interface in an Activity.
Views
2
UI elements that are drawn on-screen including buttons, lists forms etc.
Layouts
3
View hierarchies that control screen format and appearance of the views.
Intents
4
Messages wiring components together.
Resources
5
External elements, such as strings, constants and drawable pictures.
Manifest
6
Configuration file for the application.
Exploring the development environment
[Link] Android Studio welcome screen contains an option for you to open
existing projects that you might have already created in Android Studio. It also
presents options for opening a project from VCS, and importing projects from
other IDEs, such as Eclipse.
2. Click the Start a New Android Studio Project option from the Android Studio
welcome screen. You should now see the Create New Project screen,In which
enables you to configure some of the basic options for your project.
➢ The final option on the Create New Project screen is the path to which
Android Studio will save your new project. I typically accept the default
here because it makes it easier for me to find projects in the future.
Click Next to continue.
➢ The next screen allows you to select the form factor on which your
application will run.
➢ The final option on the Create New Project screen is the path to which
Android Studio will save your new project.
➢ The default option is Empty Activity. This is the most useful for our
examples because it creates a basic activity for you, with no code in it.
Click the Finish button to finish creating the project and jump into exploring the
IDE.
➢ The upper portion of the IDE represents the menu bars or ribbons.
Here, as with most applications that you have used in the past, you
have all of your options for interacting directly with the IDE.
➢ The most important ones to note are the green arrow, which represents
the Run app option, and the green arrow with a bug behind it, which is
the Debug App option.
Figure 2-6
The left side of the IDE shows the Project window, The Project window
enables you to quickly navigate the files within your project. By default, the
Project window is set to the Android view (seen just above the Project window
display). To change the view, click the word Android and use the drop-down
list of options to make the change.
• java: The Java folder contains the Java source code files. These files are
used as a controller for controlled UI (Layout file). It gets the data from the
Layout file and after processing that data output will be shown in the UI layout.
It works on the backend of an Android application.
• drawable: A Drawable folder contains resource type file (something that can
be drawn). Drawable may take a variety of file like Bitmap (PNG, JPEG), Nine
Patch, Vector (XML), Shape, Layers, States, Levels, and Scale.
• layout: A layout defines the visual structure for a user interface, such as the
UI for an Android application. This folder stores Layout files that are written in
XML language. You can add additional layout objects or widgets as child
elements to gradually build a View hierarchy that defines your layout file.
• mipmap: Mipmap folder contains the Image Asset file that can be used in
Android Studio application. You can generate the following icon types like
Launcher icons, Action bar and tab icons, and Notification icons.
• [Link]: [Link] file contains color resources of the Android
application. Different color values are identified by a unique name that can be
used in the Android application program. Below is a sample [Link] file:
<?xml version=”1.0” encoding="utf-8"?> <resources>
<color name=” colorPrimary”>#3F51B5</color> <color
name=” colorPrimaryDark”>#303F9F</color> <color
name=”
colorAccent”>#FF4081</color> </resources>
• [Link]: The [Link] file contains string resources of the Android
application. The different string value is identified by a unique name that can
be used in the Android application program. This file also stores string array
by using XML language. Below is a sample [Link] file .
<resources>
<string name=”app_name”>
Text</string> </resources>
• [Link]: The [Link] file contains resources of the theme style in the
Android application. This file is written in XML language. Below is a sample
[Link] file:
<resources>
<!-- -- Base application theme. > <style name="AppTheme"
parent="[Link]"> <!-- --
Customize your theme here. >
<item name="colorPrimary">@color/colorPrimary</item>
<item
name="colorPrimaryDark">@color/colorPrimaryDark< /item>
<item name="colorAccent">@color/colorAccent</item>
</style>
</resources>
• [Link] (Module: app): This defines the module-specific build
[Link] you can add dependencies what you need in your Android
application.
EDITOR TAB
➢ On the right side of the IDE (and taking up the largest area) are the
Editor tabs
➢ The Editor tabs are where you write and work with your code files.
➢ To work on a new file, simply locate the file in the Project window and
double-click it to open a new Editor tab that contains that file’s code. If
you need to create a new file from scratch,right-click the directory into
which you want to place your file, and select New ➪ <File Type>from
the context menu.
ANDROID MONITOR
➢ Finally, at the bottom of the IDE, you should see a button labelled
Android Monitor. Click this button to open the Android Monitor.
For Android development, you can use a Mac, a Windows PC, or a Linux
machine. You can freely download all the necessary tools.
1. JDK
2. Android Studio
3. SDK
4. AVD
The Android Studio 2 makes use of the Java SE Development Kit 8 (JDK).
If your computer does not have the JDK 8 installed, you should start by
downloading it from
[Link]/technetwork/java/javase/downloads/jdk8-
[Link]
and installing it prior to moving to the next section.
Android Studio
The first and most important piece of software you need to download is Android
Studio. After you have downloaded and installed Android Studio 2, you can use
the SDK Manager to download and install multiple versions of the Android SDK.
Having multiple versions of the SDK available enables you to write programs
that target different devices. For example, you can write one version of an
application that specifically targets Android Nougat, but because that flavor of
Android is on less than 1% of devices, with multiple versions of the SDK you
can also write a version of your app that uses older features and targets
Marshmallow or Lollipop users.
You can use the Android Device Manager to set up device emulators. You can
download Android Studio 2 from [Link]
Installation process:
8. When the install is complete, you will see a Completing Android Studio
Setup.
Leave the Start Android Studio box checked and click Finish.
Android SDK
➢ The most important piece of software you need to download is, of
course, the Android SDK.
➢ The Android SDK contains all of the packages and tools required to
develop a functional Android application.
➢ The SDKs are named after the version of Android OS to which they
correspond.
➢ By default, the Marshmallow SDK was installed with Android Studio 2.
➢ However, if you want to install a different Android SDK, you can do so
using the SDK Manager.
➢ from the Android Studio welcome screen . From this screen, click the
Configure drop-down menu in the lower-right corner.
➢ The Configure selection menu opens. Choose SDK Manager from this
menu.
➢ The SDK configuration screen, shows that the Marshmallow SDK is
already installed.
➢ The setup process for Android Studio is now complete. The next section
explains how to set up an
➢ Android Virtual Device that you can use to test your applications.
1. Start Android Studio so that the Welcome screen is visible. Click Start a
New Android Studio Project. Set up a HelloWorld [Link]
Chapter1Helloworld in the Application Name field.
2. You can keep the default values for the other fields on the New Project .
Click Next.
3. You should see the Targeted Android Devices screen. By default, the
Create New Project
4. Wizard selects for you the Android SDK level that has the greatest
activity based on statistics gathered from Google Play. For now, accept
the default, and click Next.
5. On the Add an Activity to Mobile screen, accept the default choice—
Empty Activity and click Next.
6. Accept all of the defaults on the Customize the Activity screen, and click
Finish.
7. Launch the AVD Manager by selecting Tools ➪ Android ➪ AVD Manager
or using the AVD Manager button from the toolbar.
8. Click the + Create Virtual Device button to create a new AVD. The Virtual
Device Configuration screen opens.
9. Select the Nexus 5x hardware profile and click Next. Although none of the
emulators offers the same performance as its actual hardware counterpart,
the Nexus 5x should run well on most x86-based desktops, and it still offers
some of the mid- to high-end Android device specs.
10. For the system image, select and install the latest option, which at the time
this book was written is Android Nougat. Click the x86 Images select N from
the
11. In the Android Virtual Device (AVD) dialog, accept the [Link] the
Finish button to begin building the AVD.
Debugging Your Application
Debugging is the process of finding and fixing errors or bugs in the source
code of any software.
➢ After you have built an application, you need to be able to debug it and
see what is going on inside your code.
➢ One of the handiest ways to be able to see inside your code it through
the use of breakpoints.
➢ Breakpoints allow you to pause the execution of your code at specific
locations and see what is going on (or what is going wrong).
Setting Breakpoints
➢ To tell Android Studio that you want to examine a specific line of code
during debugging, you must set a breakpoint at that line.
➢ Click the margin of the editor tab next to line of code you want to
break at, to set a breakpoint. A red circle is placed in the margin, and
the corresponding line is highlighted in red.
➢ You can also set a breakpoint by placing your cursor in the line of code
where you want it to break and clicking Run ➪ Toggle Line Breakpoint.
Notice that the term used is toggle, which means that any breakpoints
you set can be turned off the same way you turn them on.
METHOD Breakpoint
Figure 2-12
Temporary Breakpoints
foo == true
Figure 2-14
➢ While in debug mode, Android Studio pauses at any breakpoint that you
have set. That is, as long as a breakpoint has been set on a reachable
line of code (a line of code that would be executed by system),Android
Studio halts execution at that line until you tell it to continue.
➢ When Android Studio hits, and pauses at, a breakpoint, the red circle in
the margin next to the corresponding line of code changes to a circle
with a check mark.
➢ Once a breakpoint has been hit, the debug window opens at the bottom
of Android Studio.
➢ The debug window contains many of the tools you use to navigate
around your code.
➢ Notice the navigation buttons located in the menu bar of the debug
window. The most commonly used are Step Over and Step Into.
➢ Step Over advances you to the line of code that immediately follows the
one at which you are currently paused.
➢ This means that if you are paused at a method call, and you press Step
Over, Android Studio executes the method call without pausing and
then pauses again when execution reached the next line.
➢ Step Into follows execution wherever it leads in the code(i.e breakpoint
that we set) if you are paused at a method call and click Step Into,
Android Studio will shift the view to the method call and pause
execution at the first line of code within that method. This allows you to
then follow the execution of that method line-by-line before it returns to
the calling block.
Publishing Your Application
After you have created, and fully debugged, your application, you might want
to deploy it to the Google Store for others to enjoy. The following sections
outline the steps for publishing your applications.
3. Fill out all of the information on this form because it pertains to your
entity and application. Notice that there are two places for a password.
These are the passwords for your key store and your key, respectively.
Because a key store can hold multiple keys, it requires a separate
password than that of the key for a specific app.
4. Click OK to return to the Generate Signed APK window.
5. In the Generate Signed APK windows, click Next to review and finish the
process. Now that you have a signed APK, you can upload it to the Google
Play Store using the developer console at
[Link]
import [Link];
import [Link];
@Override
protected void onCreate(Bundle savedInstanceState)
{
[Link](savedInstanceState);
setContentView([Link].activity_main);
}
}
Open the app folder, and then open the subfolder manifest, and then open
the [Link] file.
Let’s suppose the reader wants to have one more activity, apart from the
MainActivity which is included by default in the project. Before adding one
more activity and not doing any changes,
• XML
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="[Link]
xmlns:tools="[Link]
package="[Link]">
<application
android:allowBackup="true"
android:dataExtractionRules="@xml/data_extraction_rules"
android:fullBackupContent="@xml/backup_rules"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/[Link]"
tools:targetApi="31">
<activity
android:name=".MainActivity"
android:exported="true">
<intent-filter>
<action android:name="[Link]" />
<category android:name="[Link]" />
</intent-filter>
</activity>
</application>
</manifest>
Now let’s add another activity named SecondActivity, and see how to declare
it in the manifest file. One must write the Declaration Code within the
application tag, otherwise, the declaration will give the error, and
SecondActitvity will not be detected by the System. The Declaration Code
is given below.
<activity
android:name=".SecondActivity"
android:exported="true" >
</activity>
Intent object:
startActivity(new Intent("[Link]"));
TYPE OF INTENT
Intent are the objects which is used in android for passing the information among
Activities in an Application and from one app to another also.
Intent are used for communicating between the Application components and it also
provides the connectivity between two apps.
EXPLICIT INTENT
Explicit intents are communicated between two activities inside the same application. We can
use explicit intents when we need to move from one activity to another activity.
Example:-
1. when a user wants to start a service to download a file or when a new activity gets
started in response to a user action.
2. In amazon app if you go to Home page you can see prime, fresh, mobies, electronics
etc. If you click prime it transit to prime page activity like wise other tab also works.
o Explicit Intent specifies the component. In such case, intent provides the external class
to be invoked.
o In Explicit we use the name of the component which will be affected by Intent.
o For Example: If we know the class name then we can navigate the app from One Activity
to another activity using Intent. In the similar way, we can start a service to download a
file in a background process.
o Explicit Intent works internally within an application to perform navigation and data
transfer.
o The below-given code snippet will help you understand the concept of Explicit Intent
IMPLICIT INTENT
• In Implicit Intents we do need to specify the name of the component. We just specify
the Action that has to be performed and further, this action is handled by the component
of another application.
• The basic example of implicit Intent is to open any web page
• Let’s take an example to understand Implicit Intent more clearly. We have to open a
website using the intent in your application. See the code snippet given below
Intent i = new Intent([Link].ACTION_VIEW,
[Link]("[Link] startActivity(i);
(OR)
The setType() method explicitly specifies the MIME data type to indicate the type of data to
return.
(A media type (also known as a Multipurpose Internet Mail Extensions or MIME type))
Intent Filters
<intent-filter> element in the manifest file to list down actions, categories and
data types associated with any activity, service, or broadcast receiver.
<activity android:name=".CustomActivity"
android:label="@string/app_name">
<intent-filter>
<action android:name="[Link]" />
<action android:name="[Link] [Link]" />
<category android:name="[Link]" />
<data android:scheme="http" />
</intent-filter>
</activity>
Once this activity is defined along with above mentioned filters, other activities
will be able to invoke this activity using either the
[Link], or using the [Link]
[Link] action provided their category
is [Link].
The <data> element specifies the data type expected by the activity to be
called and for above example our custom activity expects the data to start with
the http://
A filter <intent-filter> may list more than one action as shown above but this
list cannot be empty; a filter must contain at least one <action> element,
otherwise it will block all intents.
A filter <intent-filter> may list zero, one or more than one categories.
Each <data> element can specify a URI and a data type (MIME media type).
There are separate attributes like scheme, host, port, and path for each part
of the URI.
Android 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.
In Android, the fragment is the part of Activity which represents a
portion of User Interface(UI) on the screen.
• A fragment has its own layout and its own behaviour with its own life cycle
callbacks.
• Fragments can't live on their own. They must be hosted by an activity or
another fragment.
• You can add or remove fragments in an activity while the activity is
running.
• You can combine multiple fragments in a single activity to build a multi-
pane UI.
• A fragment can be used in multiple activities.
• Fragment life cycle is closely related to the life cycle of its host activity
which means when the activity is paused, all the fragments available in the
activity will also be stopped.
• A fragment can implement a behaviour that has no user interface
component.
You create fragments by extending Fragment class and You can insert a
fragment into your activity layout by declaring the fragment in the activity's
layout file, as a <fragment> element.
The Java class for a fragment needs to extend the Fragment base class:
FragmentTransaction fragmentTransaction =
[Link]();
Android fragments have their own life cycle very similar to an android activity.
Android Fragment Lifecycle Methods