Before you start this class, be sure you have your development
environment set up. You need to:
1. Download Android Studio.
2. Download the latest SDK tools and
platforms using the SDK Manager.
Install Android
studio
Setting up Android Studio takes just a
few clicks.
While the Android
Studio download completes, verify which version of the JDK you
have: open a command line and typejavac -version. If the JDK is not available or the version is lower than
1.8, download the Java SE Development Kit 8.
To install Android Studio on Windows,
proceed as follows:
1. Launch the .exe file
you downloaded.
2. Follow the setup wizard to install Android Studio and any
necessary SDK tools.
On
some Windows systems, the launcher script does not find where the JDK is
installed. If you encounter this problem, you need to set an environment
variable indicating the correct location.
Select Start
menu > Computer > System Properties > Advanced System Properties.
Then open Advanced tab > Environment Variables and add a
new system variable JAVA_HOME that points to your JDK folder, for example C:\Program Files\Java\jdk1.8.0_77.
Android
Architecture
Android
operating system is a stack of software components which is roughly divided
into five sections and four main layers as shown below in the architecture diagram.
Linux
kernel
At the bottom of the layers is Linux - Linux
2.6 with approximately 115 patches. This provides basic system functionality
like process management, memory management, device management like camera,
keypad, display etc. Also, the kernel handles all the things that Linux is
really good at such as networking and a vast array of device drivers, which
take the pain out of interfacing to peripheral hardware.
Libraries
On
top of Linux kernel there is a set of libraries including open-source Web
browser engine WebKit, well known library libc, SQLite database which is a
useful repository for storage and sharing of application data, libraries to
play and record audio and video, SSL libraries responsible for Internet
security etc.
Android
Runtime
This
is the third section of the architecture and available on the second layer from
the bottom. This section provides a key component called Dalvik Virtual Machine
which is a kind of Java Virtual Machine specially designed and optimized for
Android. The Dalvik VM makes use of Linux core features like memory management
and multi-threading, which is intrinsic in the Java language. The Dalvik VM enables every Android application to
run in its own process, with its own instance of the Dalvik virtual machine. The Android runtime
also provides a set of core libraries which enable Android application
developers to write Android applications using standard Java programming
language.
Application
Framework
The
Application Framework layer provides many higher-level services to applications
in the form of Java classes. Application developers are allowed to make use of
these services in their applications.
Applications
You
will find all the Android application at the top layer. You will write your
application to be installed on this layer only. Examples of such applications
are Contacts Books, Browser, Games etc.
Application Components
Application
components are the essential building blocks of an Android application. These
components are loosely coupled by the application manifest file
AndroidManifest.xml that describes each component of the application and how
they interact. There are following four main components that can be used within
an Android application:
Activities
An
activity represents a single screen with a user interface. For example, an
email application might have one activity that shows a list of new emails,
another activity to compose an email, and another activity for reading emails.
If an application has more than one activity, then one of them should be marked
as the activity that is presented when the application is launched. An activity
is implemented as a subclass of Activity class as follows:
public class MainActivity extends Activity
{
}
Services
A service is a component that runs in the
background to perform long-running operations. For example, a service might
play music in the background while the user is in a different application, or
it might fetch data over the network without blocking user interaction with an
activity. A service is implemented as a subclass of Service class as follows:
public class MyService extends Service {
Broadcast
Receivers
Broadcast Receivers
simply respond to broadcast messages from other applications or from the
system. For example, applications can also initiate broadcasts to let other
applications know that some data has been downloaded to the device and is
available for them to use, so this is broadcast receiver who will intercept
this communication and will initiate appropriate action. A broadcast receiver
is implemented as a subclass of BroadcastReceiver class and each message is
broadcasted as an Intent object.
public class MyReceiver extends BroadcastReceiver
{
}
Content
Providers
A
content provider component supplies data from one application to others on
request. Such requests are handled by the methods of the ContentResolver class.
The data may be stored in the file system, the database or somewhere else
entirely. A content provider is implemented as a subclass of ContentProvider
class and must implement a standard set of APIs that enable other applications
to perform transactions.

No comments:
Post a Comment