1) What is Android?
It is an open-sourced operating system that is used primarily on mobile devices,
such as cell phones and tablets.
It is a Linux kernel-based system that’s been equipped with rich components that
allows developers to create and run apps that can perform both basic and advanced
functions.
2) What Is the Google Android SDK?
The Google Android SDK is a toolset that developers need in order to write apps on
Android enabled devices.
It contains a graphical interface that emulates an Android driven handheld environment,
allowing them to test and debug their codes.
3) Tools Required for Developing Android Apps?
JDK
Eclipse + ADT plugin
SDK Tools.
4) Advantages of android?
Open-source
Platform-independent
Supports various technologies (having number of native application like: camera,
bluetooth, wifi, speech, EDGE)
5) What is the importance of having an emulator within the Android environment?
The emulator lets developers “play” around an interface that acts as if it were an actual
mobile device.
They can write and test codes, and even debug. Emulators are a safe place for testing
codes especially if it is in the early design phase.
6) What is the use of an activityCreator?
An activityCreator is the first step towards the creation of a new Android project.
It is made up of a shell script that will be used to create new file system structure
necessary for writing codes within the Android IDE.
7) Describe Activities
Activities are what you refer to as the window to a user interface.
Just as you create windows in order to display output or to ask for an input in the form of
dialog boxes, activities play the same role, though it may not always be in the form of a
user interface.
An activity is a single, focused thing that the user can do. whenever user click on GUI
the next Activity will be start and new GUI set base on coding.
8) What are Intents?
Intent is exactly what it describes. It's an "intention" to do an action.
Intent is basically a message to say you did or want something to happen.
Depending on the intent, apps or the OS might be listening for it and will react
accordingly.
There are two types of intents in android:
Implicit Intent
Explicit Intent
Intents displays notification messages to the user from within the Android enabled
device.
It can be used to alert the user of a particular state that occurred. Users can be made to
respond to intents.
9) How to Start another Activity?
Intent i = new Intent(getApplicationContext(), Activity2.class);
startActivity(i);
Note: you need to past this code on onClick method.
10) Android application main components are?
Components Description
They dictate the UI and handle the user interaction to
Activities
the Smartphone screen
They handle background processing associated with
Services
an application.
They handle communication between Android OS
Broadcast Receivers
and applications.
Content Providers They handle data and database management issues
Activities
An activity represents a single screen with a user interface; in-short Activity performs
actions on the screen.
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 broadcaster as an Intent object.
public class MyReceiver extends BroadcastReceiver {
public void onReceive(context,intent){}
}
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.
public class MyContentProvider extends ContentProvider
{
public void onCreate(){}
}
11) What do you think are some disadvantages of Android?
Given that Android is an open-source platform, and the fact that different Android
operating systems have been released on different mobile devices, there’s no clear cut
policy to how applications can adapt with various OS versions and upgrades.
One app that runs on this particular version of Android OS may or may not run on
another version.
Another disadvantage is that since mobile devices such as phones and tabs come in
different sizes and forms, it poses a challenge for developers to create apps that can
adjust correctly to the right screen size and other varying features and specs.
12) Android latest version Lolipop 5.0
13) What is the AndroidManifest.xml?
This file is essential in every application.
It is declared in the root directory and contains information about the application that the
Android system must know before the codes can be executed.
Applications declare their components in a manifest file that's bundled into the Android
package, the .apk file that also holds the application's code, files, and resources.
The manifest is a structured XML file and is always named AndroidManifest.xml for all
applications.
It is also used for naming any libraries the application needs to be linked against
(besides the default Android library) and identifying any permission the application
expects to be granted.
14) What is the significance of the .dex files?
Android programs are compiled into .dex (Dalvik Executable) files, which are in turn
zipped into a single .apk file on the device.
.dex files can be created by automatically, translating compiled applications written in
the Java programming language.
15) Describe the APK format.
The APK file is compressed the
AndroidManifest.xml file
application code (.dex files)
resource files
A project is compiled into a single .apk file.
16) What are the different tools in Android? Explain them?
The Android SDK and Virtual Device Manager-
It is used to create and manage Android Virtual Devices (AVD) and SDK packages. The
AVD hosts an emulator running a particular build of Android, letting you specify the
supported SDK version, screen resolution, amount of SD card storage available, and
available hardware capabilities (such as touch screens and GPS).
The Android Emulator-
An implementation of the Android virtual machine designed to run within a virtual device
on your development computer. Use the emulator to test and debug your Android
applications.
Dalvik Debug Monitoring Service (DDMS) –
Use the DDMS perspective to monitor and control the Dalvik virtual machines on which
you're debugging your applications.
Android Asset Packaging Tool (AAPT) –
Constructs the distributable Android package files (.apk).
Android Debug Bridge,(adb) –
Android Debug Bridge, is a command-line debugging application shipped with the SDK.
It provides tools to browse the device, copy tools on the device, and forward ports for
debugging.
17) Type of Android Application?
1. Foreground :
An application that’s useful only when it’s in the foreground and is effectively suspended
when it’s not visible. Games and Map mashups are common example.
2. Background :
An application with limited interaction that, apart from when being configured , spends
most of its lifetime hidden. Examples include call screening applications and SMS auto-
responders.
3. Intermittent :
Expects some interactivity but does most of its work in the background. often these
applications will be set up and then run silently, notifying users when appropriate. A
common example would be a media player.
4. Widget :
Some Application are represented only as a home-screen widget.
How application works in android:
First the init() is executed.
init starts Linux daemons that are usbd,adbd,adb,rild etc.These are used for low level
hardware interfaces.
on the top of the hardware abstraction layer.
After callig deamons init calls the Zygote() which initialize the dalvik VM and load the
classes and libraries
Copy on write to maximize the use and minimize the footprint.
Then init starts run time process, initializes the service manager. provides the local look
services.
Then runtime sends request to the Zygote that it is ready to start system service.
So Zygote will fork the new VM and start the service. System server is now started.
So system server will start the audio flnger and surface flinger. i.e. system i/p o/p
devices.
These will register to the service manager that they are available for higher level
services.
Then system service starts the android managed services i.e. content
manger,windowmanager
These are registered to service manager through java proxy object which is passed
down to service manager.
So it’s a java representation in service manager that it is ready to accept the calls from
other applications
Android Application Building Blocks
• Android Application Components:
– Activity:
» basic application class with views and can respond to user input
– Intent:
» request to do something, used to move from screen to screen
– Content Provider:
» Structured data storage and access
– Service
» Long term running backend processes
– AndroidManifest.xml:
» required global description file
<?xml version="1.0" encoding="utf-8" ?>
- <LinearLayout
android:id="@+id/LinearLayout01"xmlns:android="http://schemas.android.com/apk/
res/android" android:orientation="vertical" android:layout_width="fill_parent"
android:layout_height="fill_parent">
<LinearLayout android:id="@+id/LinearLayout02"
android:layout_width="wrap_content" android:layout_height="wrap_content"
android:orientation="horizontal" />
- <LinearLayout android:id="@+id/LinearLayout03"
android:layout_width="wrap_content" android:layout_height="wrap_content"
android:orientation="horizontal">
<Button android:layout_width="wrap_content" android:layout_height="wrap_content"
android:id="@+id/ButtonStreetView" android:text="Street" />
<Button android:layout_width="wrap_content" android:layout_height="wrap_content"
android:id="@+id/ButtonSateliteView" android:text="Satelite" />
<Button android:layout_width="wrap_content" android:layout_height="wrap_content"
android:id="@+id/ButtonZoomIn" android:text="ZoomIn" />
<Button android:layout_width="wrap_content" android:layout_height="wrap_content"
android:id="@+id/ButtonZoomOut" android:text="ZoomOut" />
</LinearLayout>
<com.google.android.maps.MapView android:id="@+id/myMapView"
android:layout_width="fill_parent" android:layout_height="fill_parent"
android:enabled="true" android:clickable="true" android:apiKey="02IRLexcXjhME-
s8mKHAL3Pxp-3JbWkuvVFbF5g" />
- <!-- android:apiKey="0LxDPzenu-iEvtJH775DMQcz6RYOsi2JsImYdyA"
-->
</LinearLayout>