2. Contents
Introduction of Android
What is Android Studio?
Starting up with Android Studio.
Creating an application.
3. What is Android ?
In English dicitionary the world android means that-
An automation that resambles a human being,
Mechanical man or humanoid …..etc.
Android is an open source operating system
specifically for use on mobile devices ( smart phones
and tablets).
Based on the Linux kernel(2.6 kernel).
Developed by Google and later by the Open Handset
Alliance(OHA).
Allows writing managed code in the Java language.
4. Android has its own virtual machine i.e , DVM (Dalvik
Virtual Machine), which is used for executing the
android applications.
Supports Bluetooth, Wi-Fi, and 3G and 4G
networking.
5. Android Studio
Android Studio is a new Android development
environment developed by Google. It is based on
IntellJ IDEA, which is similar to Eclipse with the ADT
(Android Development Toolkit) plugin .
It is different from Eclipse in many ways. The most
basic difference is that we do’n’t have to do any
configuration like we would have do to for Eclipse.
Android Studio comes bundled with the Android ADT,
and all we need to do is to point it to where Java is
installed on our s/s .
6. JDK version must be later than version 6.
Once downloaded, you can follow the set-up wizard.
At times, for Windows systems, the launcher script
isn’’t able to find Java. So we need to set an
environment variable called JAVA_HOME and point it
to our JDK folder.
Now that the set-up is complete, we can go ahead and
directly launch the Android Studio. There is no need
to download the ADT plugin and configure it. When
we launch it, we can see the Welcome screen (refer to
Figure 2).
7. Some specific features that come with Android Studio
(and quoting directly from the Android Developers
Web page):
Gradle-based build support.
Android-specific refactoring and quick fixes
Lint tools to improve performance, usability, version
compatibility .
ProGuard and app-signing capabilities.
A rich layout editor that allows you to drag-and-drop
UI components, preview layouts on multiple screen
configurations, and much more.
9. Creating a New Project
The first step in the application development process is to
create a new project within the Android Studio
environment. Begin, therefore, by launching Android
Studio so that the “Welcome to Android Studio” screen
appears as illustrated in Figure 2:
11. Once this window appears, Android Studio is ready for a
new project to be created. To create the new project, simply
click on the Start a new Android Studio project option to
display the first screen of the New Project wizard as shown
in Figure 3:
12. Defining the Project
In the New Project window, set the Application name field
to AndroidSample(Fig 3). The application name is the
name by which the application will be referenced and
identified within Android Studio.
The Package Name is used to uniquely identify the
application within the Android application ecosystem. It
should be based on the reversed URL of your domain name
followed by the name of the application. For example, if
our domain is www.mycompany.com, and the application
has been named AndroidSample , then the package name
might be specified as follows:
com.example.parinita.androidsample
13. The Project location setting will define our project will
be get store(Fig 3).
Click Next to proceed.
15. Selecting the form factors
On the form factors screen, enable the Phone and
Tablet option and set the minimum SDK setting to API
8: Android 4.0.3 (IceCremeSandwich) . The reason for
selecting an older SDK release is that this ensures that
the finished application will be able to run on the
widest possible range of Android devices.
Since the project is not intended for Google TV, Google
Glass or wearable devices, leave the remaining options
disabled before clicking Next.
17. Selecting an Activity
The next step is to define the type of initial activity
that is to be created for the application. A range of
different activity types is available when developing
Android applications. Here we select the option to
create a Blank Activity.
19. With the Blank Activity option selected, click Next.
On the final screen (Figure 6) name the:
Activity Name: Name of the activity to load.
Layout Name : Every screen (activity) UI is designed
using an XML File. This layout will define the layout of
the activity.
Title : It is the title of the activity.
Menu Resource Name : This file will decide what
should be displayed when the user clicks on the Menu
of the android app screen.
23. Important files and directory of Android project to be
known and their purpose :
src - This contains the .java source files for our project.
By default, it includes an AndroidSampleActivity.java
source file having an activity class that runs when your
app is launched using the app icon.
generated - This contains the .R file, a compiler-
generated file that references all the resources found in
your project.
bin - This folder contains the Android package files
.apk built by the ADT during the build process and
everything else needed to run an Android application.
24. res/layout - This is a directory for files that define your
app's user interface.
res/values - This is a directory for other various XML
files that contain a collection of resources, such as
strings and colors definitions.
AndroidManifest.xml - This is the manifest file which
describes the fundamental characteristics of the app
and defines each of its components.
25.
26. Layout File
The activity_android_sample.xml is a layout file available
in res/layout directory, that is referenced by our application
when building its interface.
String file
The strings.xml file is located in the res/values folder and it
contains all the text that our application uses. For example,
the names of buttons, labels, default text, and similar types
of strings go into this file. This file is responsible for their
textual content.
The gen/com.example.parinita.androidsample/R.java file
is the glue between the activity Java files like
AndroidSampleActivity.java and the resources like
strings.xml. It is an automatically generated file and we
should not modify the content of the R.java file.
29. Running the app on Emulator
The Android SDK includes a mobile device emulator
— a virtual mobile device that runs on our computer.
The emulator lets us develop and test Android
applications without using a physical device.
Emulator can be started from SDK manager tools.
The Android SDK separates tools, platforms, and other
components into packages such as debugger, libraries,
an emulator, documentation, sample code.
30.
31. AVD Manager
An Android Virtual Device or AVD is an emulator
configuration, allowing you to model an Android
device. This makes running and testing applications
on a wide range of devices much easier. With an
Android Virtual Device, we can specify the hardware
and software the Android Emulator needs to
emulate.
The preferred way to create an Android Virtual Device
is through the AVD Manager, which can be access in
Android Studio by selecting Android > AVD
Manager from the Tools menu.
32.
33. To use newly created AVD, select it from the list in the
AVD manager, and click Start. If AVD is set up
correctly, the Android Emulator should launch as
shown in the screenshot below.
34.
35. With the Android Emulator up and running, it's time
to launch the application by selecting Run from
the Run menu. And our application runs on the
Android Emulator.