Professional Documents
Culture Documents
Android Project
PROJECT
REPORT
Root Finder and Measurements
Root Finder and Measurements project is based on Android Platform that helps to find the root
between two places and gives the distance between them. It makes very easy for travellers to travel at
different location.
ON
ON
ANDROID
Submitted By:NAME:-
ROHIT YADAV
Page 0 of 82
Android Project
ACKNOWLEDGEMENT
The satisfaction that accompanies the successful completion of any task would
be incomplete without the mention of people whose ceaseless cooperation made
it possible, whose constant guidance and encouragement crown all efforts with
success.
I would like to take this opportunity to express my gratitude towards all the
people who have in various ways, helped in the successful completion of my
project. Many books are the result of a collection from various sources, such as
internet, newspapers, magazines etc. Unfortunately, sources were not always
noted or accurate acknowledgement.
Page 1 of 82
Android Project
CONTENTS
Introduction to Android
Layout File
Create Layout File
Attributes
Attributes Id
References view in java code
Layout Types
Linear Layout
Relative Layout
Table Layout
Frame Layout
Tab Layout
Software Development
Eclipse With Emulator..
Camera Hardware And Application..
Permission
Image Capture Intent
Video Capture Intent
Building A Camera Application
Checking Camera Features
Placing Preview a Layout
View.
Advantages
Disadvantages
Android Architecture
Applications
Application Framework
Libraries
Android Runtime
Linux Kernel
Widgets
Text View
Auto Text
Editable
Release Process..
Animation.
Tweened Animation
Alpha Animation
Rotate Animation
Translate Animation
Page 2 of 82
Android Project
Scale Animation
Conclusion
Page 3 of 82
Android Project
Page 4 of 82
Android Project
INTRODUCTION
TO ANDROID
Page 5 of 82
Android Project
INTRODUCTION TO ANDROID
Android is an open source software stack that includes the
operating system, middleware and key applications along with the set
of API Libraries for writing mobile applications that can shape the
look, feel and functions of the mobile handsets. It uses the java
programming language with XML, Android SDK tools (Software
development toolkit) and necessary API to develop the applications
on android platform.
Android will ship with a set of core applications including an
email client, SMS Program, Calendar, maps, browser, contacts and
many other applications. All applications are written in Java
Programming language and XML By using Android SDK and APIs.
Android provides many features that help to create a new
application for mobile handsets. It provides the following features to
develop the new applications.
Application framework enabling reuse and replacement of
components.
Dalvik Virtual Machine (DVM) optimized for mobile devices.
Integrated Web Browser based on open source web kit Engine.
Optimized Graphics powered by a custom 2D Graphics
library; 3D Graphics based on the openGL ES 1.0 specifications
(hardware acceleration optional).
SQLite for structure data storage.
Media Support for common audio, video, and still image
formats (MPEG4, MP3, H.264, AAC, AMR, JPEG, PNG, and
GIF).
GSM Telephony (hardware dependent).
Bluetooth, Edge, 3G and WIFI (hardware dependent).
Page 6 of 82
Android Project
Camera, GPS, Compass, accelerometer (hardware
dependent).
Rich Development Environment including a device emulator,
tools for debugging, memory and performance profiling, and a
plugin for Eclipse IDE.
ADVANTAGES
Fast & easy application development
Android is open-source Linux software.
Android is free of cost.
The ability for anyone to customize the Google Android
platform will open up the applications playing field to small and
new companies.
In addition, as a result of many mobile phones carrying Google
Android, companies will come up with such innovative products
like the location aware services that will provide users with any
information they might be in need of. This information could
include knowing the location of a nearby convenience store or
filling station.
DISADVANTAGE
Android is an open source platform driving all Android phones,
it could significantly increase the risk of hacking these devices.
It only best suited for high-end phones.
ANDROID ARCHITECTURE
Page 7 of 82
Android Project
The following diagrams show the major components of the
android operating system. Each section is described in detail in
below.
Page 8 of 82
Android Project
Applications
Android Project
Underlying all applications is a set of services and systems, including:
Libraries
Page 10 of 82
Android Project
System C library - a BSD-derived implementation of the
standard C system library (libc), tuned for embedded Linuxbased devices
Media Libraries - based on Packet Videos Open CORE; the
libraries support playback and recording of many popular audio
and video formats, as well as static image files, including
MPEG4, H.264, MP3, AAC, AMR, JPG, and PNG
Surface Manager - manages access to the display subsystem and
seamlessly composites 2D and 3D graphic layers from multiple
applications
Lib Web Core - a modern web browser engine which powers
both the Android browser and an embeddable web view
SGL - the underlying 2D graphics engine
3D libraries - an implementation based on OpenGL ES 1.0 APIs;
the libraries use either hardware 3D acceleration (where
available) or the included, highly optimized 3D software
rasterizer
Free Type - bitmap and vector font rendering
SQLite - a powerful and lightweight relational database engine
available to all applications
C/C++ libraries
Interface through Java
Surface manager Handling UI Windows
2D and 3D graphics
Media codecs, SQLite, Browser engine
Android Runtime
What makes an Android phone an Android phone rather than a
mobile Linux implementation is the Android run time. Including the
core libraries and the Dalvik virtual Machine, the Android run time is
Page 11 of 82
Android Project
the engine that powers your applications and, along with the libraries,
forms the basis for the application framework.
Linux Kernel
Page 12 of 82
Android Project
Page 13 of 82
Android Project
Services
Broadcast Receivers
Receives
and
reacts
to
broadcast
announcements
An application can announce to whoever is
listening that a picture was taken.
Content Providers
Intents
Android Project
activity resumes, you can reacquire the necessary resources and
resume actions that were interrupted. These state transitions are all
part of the activity lifecycle.
Android Activity Lifecycle
Application run in their own processes (VM, PID)
Processes are started and stopped as needed to run an application's
components
Processes may be killed to reclaim resources
Method
On Create()
On Restart()
Description
Killabl Next
e after?
Called when the activity is first No
On Start()
created. This is where you should
do all of your normal static set up
create views, bind data to lists,
and so on. This method is passed a
Bundle object containing the
activity's previous state, if that
state was captured (see Saving
Activity State, later).
Always followed by on Start ().
No
On Start()
On Resume()
or
on Stop()
On Pause()
Page 15 of 82
Android Project
On Pause()
On Stop()
on Destroy()
On Resume()
or
on Stop()
On Restart()
or
on Destroy()
Nothing
Page 16 of 82
Android Project
the
system
is
temporarily
destroying this instance of the
activity to save space. You can
distinguish between these two
scenarios with the is Finishing()
method.
Page 17 of 82
Android Project
Services
Faceless components that run in the background
E.g. music player, networks download etc
Page 18 of 82
Android Project
Broadcast Receivers
Base class for code that will receive intents sent by sendBroadcast
(). You can either dynamically register an instance of this class with
Context.registerReceiver () or statically publish an implementation
through the <receiver> tag in your AndroidManifest.xml. Note: If
registering a receiver in your Activity.onResume ()
implementation, you should unregister it in Activity.onPause (). Do
not unregister in Activity.onSaveInstanceState (), because this
won't be called if the user moves back in the history stack.
There are two major classes of broadcasts that can be received:
Normal broadcasts (sent with Context. SendBroadcast) are
completely asynchronous. All receivers of the broadcast are
run in an undefined order, often at the same time. This is
more efficient, but means that receivers cannot use the result
or abort APIs included here.
Ordered broadcasts are delivered to one receiver at a time.
As each receiver executes in turn, it can propagate a result to
the next receiver, or it can completely abort the broadcast so
that it won't be passed to other receivers. The order receivers
run in can be controlled with the android: priority attribute of
the matching intent-filter; receivers with the same priority
will be run in an arbitrary order.
Content Providers
Enables sharing of data across applications
E.g. address book, photo gallery
Provides uniform APIs for:
querying
delete, update and insert.
Page 19 of 82
Android Project
Content is represented by URI and MIME type
Intents
Think of Intents as a verb and object; a description of what you
want done
E.g. VIEW, CALL, PLAY etc..
System matches Intent with Activity that can best provide the
service
Activities and Intent Receivers describe what Intents they can
service
The Applications Manifest
Declares the permissions the application will need
permission)
(uses-
Android Project
App.
IMPLEMENTATION
Cheap: Install the tools
Java, Eclipse, Android SDK
Your computer: Windows, Linux, Mac
Phone emulator included
Easy: Create your first program
Android Development Toolkit (ADT)
Plugin for Eclipse, written by Google
Examples and tutorials available
Run on the Emulator
Verify by USB connecting a phone to computer
Rewarding: Prepare to publish e.g. Google Market
KEY TOOLS
Linux, Windows, Mac OSX
Java (Oracle/Sun)
o Java SDK 6 update 22
SDK (Google)
o Android SDK r7
Eclipse
o Eclipse 3.6.1
What is a Layout ?
Page 21 of 82
Android Project
1. Your layout is the architecture for the user interface an
Activity.
2. It defines the layout structure and holds all the visual elements
that appear to the user.
Android Project
You could declare your application's default layouts in XML,
including the visual elements that will appear in them and their
properties. (Option #1).
You could then add code in your application that would modify
the state of the visual elements declared in XML, at run time.
(Option #2).
Advantages of Option #1:
Declaring UI in XML
Layout File
Layout File Structure
A layout specifies a hierarchical tree structure of
ViewGroup and View elements
A ViewGroup is considered as a branch
A View is considered as leaf.
Page 23 of 82
Android Project
A layout file must contain exactly one root element, which
must be one of the following
ViewGroup element (i.e., LinearLayout) - typical
View element (Button, for example)
A ViewGroup element can have child elements, Which
themselves can be ViewGroup or View elements
Example: Layout File
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
<TextView android:id="@+id/text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Hello, I am a TextView" />
<Button android:id="@+id/button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Hello, I am a Button" />
</LinearLayout>
Page 24 of 82
Android Project
Android Project
}
Attributes
Attributes
Every View and ViewGroup element has a set of attributes.
Some attributes are specific to a View element (for
example, TextView supports the textSize attribute)
but these attributes are also inherited by any View
elements that may extend this element.
Some are common to all View elements, because
they are inherited from the root View element (like
the id attribute).
Other attributes are considered "layout parameters,"
which are attributes that describe certain layout
orientations of the View element, as defined by that
Objects parent ViewGroup object.
These attributes are typically in XML form but can be
set programmatically
Attributes: ID
ID Attribute
A View element has an integer ID associated
with it, to uniquely identify the View within the
tree.
When the application is compiled, this ID is
referenced as an integer, but the ID is typically
assigned in the layout XML file as a string, in
the id attribute
android:id="my_own_id"
Syntax - @+id specifies that you ask the
Android system to generate an ID
android:id="@+id/my_button"
Page 26 of 82
Android Project
Android's Built-in Resource ID
Android framework comes with its own built-in
resources
When referencing an Android's built-in resource
in the layout resource file, you do not need the
plus-symbol, but must add the android package
namespace
android:id="@android:id/empty"
When referencing an Android's built-in resource
in the Java code, it is referenced throug
android.R.id.empty
Attributes:
Layout Parameters
What Are Layout Parameters?
XML layout attributes named
layout_<something> define layout parameters
Page 27 of 82
Android Project
for the View that are appropriate for the ViewGroup in
which it resides
Parent view group defines layout parameters for each child view
(including the child view group)
Android Project
Same as fill_parent
Introduced in API Level 8
<Button android:id="@+id/my_button"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/my_button_text"/>
layout_weight attribute
Is used in a LinearLayout to assign
"importance" to child Views within that layout.
All Views have a default layout_weight of zer
They take up only as much room on the screen as they need to
be displayed
Assigning a value higher than zero will split up the rest of
the available space in the parent View
<each View's layout_weight>/<total value of layout_weight of
all View's>
Layout Types
All layout types are subclass of ViewGroup class
Layout types
LinearLayout
RelativeLayout
TableLayout
Page 29 of 82
Android Project
FrameLayout
Tab layout
LinearLayout
Aligns all children in a single direction vertically or horizontally,
depending on how you define the orientation attribute.
All children are stacked one after the other, so a vertical
list will only have one child per row, no matter how wide
they are
A LinearLayout respects
margins between children
gravity (right, center, or left alignment) of each child.
weight to each child
Page 30 of 82
Android Project
LinearLayout organizes elements along a single line. You
specify whether that line is verticle or horizontal using
android:orientation. Here is a sample Layout XML using
LinearLayout.
RelativeLayout
RelativeLayout lets child views specify their position
relative to the parent view or to each other (specified by
ID)
You can align two elements by right border, or make one
below another, centered in the screen, centered left, and so
on
Elements are rendered in the order given
If the first element is centered in the screen, other
elements aligning themselves to that element will be
aligned relative to screen center.
RelativeLayout Example
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="@drawable/blue"
android:padding="10px" >
<TextView android:id="@+id/label"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="Type here:" />
<EditText android:id="@+id/entry"
Page 31 of 82
Android Project
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="@android:drawable/editbox_background"
android:layout_below="@id/label" />
<Button android:id="@+id/ok"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@id/entry"
android:layout_alignParentRight="true"
android:layout_marginLeft="10px"
android:text="OK" />
<Button android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_toLeftOf="@id/ok"
android:layout_alignTop="@id/ok"
android:text="Cancel" />
</RelativeLayout>
TableLayout
TableLayout positions its children into rows and
columns
TableRow objects are the child views of a
TableLayout
Page 32 of 82
Android Project
Each TableRow defines a single row in the table
Each row has zero or more cells, each of which is
defined by any kind of other View.
Columns can be
Hidden
Stretch and fill the available screen space
Shrinkable to force the column to shrink until the
table fits the screen.
TableLayout Example
<?xml version="1.0" encoding="utf-8"?>
<Tablelayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:stretchColumns="1">
<TableRow>
<TextView
android:text="@string/table_layout_4_open"
android:padding="3dip" />
<TextView
android:text="@string/table_layout_4_open_shortcut"
android:gravity="right"
android:padding="3dip" />
</TableRow>
<TableRow>
<TextView
android:text="@string/table_layout_4_save"
android:padding="3dip" />
<TextView
Page 33 of 82
Android Project
android:text="@string/table_layout_4_save_shortcut"
android:gravity="right"
android:padding="3dip" />
</TableRow>
</TableLayout>
FrameLayout
FrameLayout is the simplest type of layout
object. It's basically a blank space on your
screen that you can later fill with a single object
For example, a picture that you'll swap in and out.
All child elements of the FrameLayout are
pinned to the top left corner of the screen; you
cannot specify a different location for a child
view.
Subsequent child views will simply be drawn over
previous ones, partially or totally obscuring them
(unless the newer object is transparent).
FrameLayout Example
<FrameLayout
xmlns:android="http://schemas.android.com/apk/res/androi"
android:layout_width="match_parent"
android:layout_height="match_parent">
Page 34 of 82
Android Project
<TextView
android:text="yellowyellowyellow"
android:gravity="bottom"
android:background="#aaaa00"
android:layout_width="wrap_content"
android:layout_height="120dip"/>
<TextView
android:text="greengreengreen"
android:gravity="bottom"
android:background="#00aa00"
android:layout_width="wrap_content"
android:layout_height="90dip" />
<TextView
android:text="blueblueblue"
android:gravity="bottom"
android:background="#0000aa"
android:layout_width="wrap_content"
android:layout_height="60dip" />
<TextView
android:text="redredred"
android:gravity="bottom"
android:background="#aa0000"
android:layout_width="wrap_content"
android:layout_height="30dip"/>
</FrameLayout>
Page 35 of 82
Android Project
Tab Layout
A tab has
Tab indicator
Content
Tag
Tab indicator can be
Label or
Label and Icon
Tab content
View
Runtime creation via TabHost.TabContentFactory
Activity
Page 36 of 82
Android Project
Android Project
A set of tab labels that the user clicks to select a
specific tab.
FrameLayout object that displays the contents of
that page.
SOFTWARE DEVELOPMENT
Android Project
The figure above shows the relevant components for the integration of
an emulator into Eclipse. The device or emulator type corresponds to
the emulator type; the states and operations describe the state machine
whereby the user controls the emulator from the Eclipse workbench;
the service definitions link the operations (or services) to the
device/emulator type; and the wizard is used to create instances of a
given device or emulator type.
Page 39 of 82
Android Project
Deployment framework
One vital part in mobile development is testing on real devices. To
make that as easy as possible the developer must have methods to
transfer mobile applications to handheld devices using local methods
(e.g. Bluetooth, USB, IrDA). The idea of MTJ is to develop a
framework that provides an API for vendor specific plug-ins, which
then do the actual deployment.
Page 40 of 82
Android Project
/>
/>
Page 41 of 82
Android Project
he Android framework supports capturing images and video
through the Camera API or camera Intent. Here are the relevant
classes:
1-Camera:- This class is the primary API for controlling device
cameras. This class is used to take pictures or videos when you
are building a camera application.
2-SurfaceView:- This class is used to present a live camera
preview to the user.
3-MediaRecorder:- This class is used to record video from the
camera.
4-Intent:-An
intent
action
type
of MediaStore.ACTION_IMAGE_CAPTUREor MediaStore.A
CTION_VIDEO_CAPTURE can be used to capture images or
videos without directly using the Camera object.
Using Existing Camera Apps
First Step-Compose a Camera Intent - Create an Intent that
requests an image or video, using one of these intent
types:MediaStore.ACTION_IMAGE_CAPTURE - Intent
action type for requesting an image from an existing
camera application.
MediaStore.ACTION_VIDEO_CAPTURE - Intent action type
for requesting a video from an existing camera application
Second
Step-Start
the
Camera
Intent Use
the startActivityForResult() method to execute the camera
intent. After you start the intent, the Camera application
user interface appears on the device screen and the user
can take a picture or video.
Page 42 of 82
Android Project
Third Step-Receive the Intent Result - Set up
an onActivityResult() method in your application to
receive the callback and data from the camera intent.
When the user finishes taking a picture or video (or
cancels the operation), the system calls this method
Page 43 of 82
Android Project
@Override
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.main); // create Intent to take a picture
and
return
control
to
the
calling
application
Intent
intent
=
new
Intent(MediaStore.ACTION_IMAGE_CAPTURE);
fileUri = getOutputMediaFileUri(MEDIA_TYPE_IMAGE);
//create a file to save the image
intent.putExtra(MediaStore.EXTRA_OUTPUT, fileUri); // set
the
image
file
name
startActivityForResult(intent,
CAPTURE_IMAGE_ACTIVITY_REQUEST_CODE);
}
Page 44 of 82
Android Project
When the startActivityForResult() method is executed, users
see a camera application interface. After the user finishes taking
a picture (or cancels the operation), the user interface returns to
your application, and you must intercept the onActivityResult()
method to receive the result of the intent and continue your
application execution. For information on how to receive the
completed intent, see Receiving camera intent result.
Video capture intent
MediaStore.EXTRA_OUTPUT- This setting requires a Uri
specifying a path and file name where you'd like to save the
video. This setting is optional but strongly recommended. If you
do not specify this value, the Camera application saves the
requested video in the default location with a default
name,specified in the returned intent's Intent.getData() field.
MediaStore.EXTRA_VIDEO_QUALITY- This value can be 0
for lowest quality and smallest file size or 1 for highest quality
and larger file size.
MediaStore.EXTRA_DURATION_LIMIT - Set this value to
limit the length, in seconds, of the video being captured.
MediaStore.EXTRA_SIZE_LIMIT- Set this value to limit the
file size, in bytes, of the video being captured.
Private static final
intCAPTURE_VIDEO_ACTIVITY_REQUEST_CODE=200;
privateUrifileUri;
@Override
public
void
onCreate(Bundle
savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.main);//create
new
Intent
Intent
intent
=
new
Page 45 of 82
Android Project
Intent(MediaStore.ACTION_VIDEO_CAPTURE);
fileUri = getOutputMediaFileUri(MEDIA_TYPE_VIDEO);
//create
a
file
to
save
the
video
intent.putExtra(MediaStore.EXTRA_OUTPUT, fileUri); // set
the
image
file
name
intent.putExtra(MediaStore.EXTRA_VIDEO_QUALITY, 1); //
set the video image quality to high// start the Video Capture
Intent
startActivityForResult(intent,
CAPTURE_VIDEO_ACTIVITY_REQUEST_CODE);
}
Building a Camera App
Detect and Access Camera - Create code to check for the
existence of cameras and request access.
Create a Preview Class - Create a camera preview class that
extends SurfaceView and
implements
the SurfaceHolder
interface. This class previews the live images from the camera.
Build a Preview Layout - Once you have the camera preview
class, create a view layout that incorporates the preview and the
user interface controls you want.
Setup Listeners for Capture - Connect listeners for your
interface controls to start image or video capture in response to
user actions, such as pressing a button.
Capture and Save Files - Setup the code for capturing pictures
or videos and saving the output.
Release the Camera - After using the camera, your application
must properly release it for use by other applications.
Page 46 of 82
Android Project
Checking camera features
Once you obtain access to a camera, you can get further
information
about
its
capabilities
using
the Camera.getParameters() method and checking the
returnedCamera.Parameters object for supported capabilities.
When
using
API
Level
9
or
higher,
use
the Camera.getCameraInfo() to determine if a camera is on the
front or back of the device, and the orientation of the image
Creating a preview class
For users to effectively take pictures or video, they must be able
to see what the device camera sees. A camera preview class is
a SurfaceView that can display the live image data coming from
a camera, so users can frame and capture a picture or video.
The following example code demonstrates how to create a basic
camera preview class that can be included in a View layout.
This class implements SurfaceHolder.Callback in order to
capture the callback events for creating and destroying the view,
which are needed for assigning the camera preview input.
Page 47 of 82
Android Project
The Camera class uses different callback interface to report
different events to the application. The following callback
interfaces are used to notify the events Camera.AutoFocusCallback
Camera.ErrorCallback
Camera.PictureCallback
Camera.PreviewCallback
Camera.ShutterCallback
Android Project
3-After taking a picture, preview display will have stopped. To
take more photos, call startPreview() again first.
4-Call stopPreview() to stop updating the preview surface.
5-Important: Call release() to release the camera for use by other
applications. Applications should release the camera
immediately in onPause() (and re-open() it in onResume()).
View
This class represents the basic building block for user interface
components. A View occupies a rectangular area on the screen
and is responsible for drawing and event handling. View is the
base class for widgets, which are used to create interactive UI
components (buttons, text fields, etc.). The ViewGroup subclass
is the base class for layouts, which are invisible containers that
hold other Views (or other ViewGroups) and define their layout
properties.
All of the views in a window are arranged in a single tree. You
can add views either from code or by specifying a tree of views
in one or more XML layout files. There are many specialized
subclasses of views that act as controls or are capable of
displaying text, images, or other content.
Widgets
TextView
EditText
Button
Page 49 of 82
Android Project
ImageView
ImageButton
Spinner
List
Property Of Widgets
ID
Position
Size
Padding
Margin
Layout
EventHandling And Threading
Focus
TouchMode
Scrolling
Animation
Security
TextView
The simplest widget is the label, referred to in Android as a
TextView. Like in most GUI toolkits, labels are bits of text not
editable directly by users
Page 50 of 82
Android Project
TextView control usage would be to display textual labels for
other controls, like Enter a Date:, Enter a Name: or Enter a
Password:.
AutoText
If set (true), finds and corrects simple spelling errors in the text.
Editable
If set (true), indicates that the program has defined an input method
to receive input text (default is false for TextView
RELEASE PROCESS
Animation
There are two ways to create animations via XML
declaration or in a Java class. Were going to focus on
Page 51 of 82
Android Project
Android Project
OvershootInterpolator and CycleInterpolator. For example the
BounceInterpolator gives an bouncing effect once the animation
is almost over. Please check the Javadoc for the rest of the
Interpolator classes
Tweened animations.
Alpha Animation
Alpha animations allows us to create fade-in/fade-out effects
All animations are stored in res/anim so we create a new xml
file named alpha.xml there.
An animation that controls the alpha level of an object. Useful
for fading things in and out. This animation ends up changing
the alpha property of a Transformation.
<?xml version="1.0" encoding="utf-8"?>
<alpha
xmlns:android=http://schemas.android.com/apk/res/android
android:fromAlpha="0.0"
android:toAlpha="0.9"
android:duration="4000" />
fromAlphaStarting alpha value for the animation, where 1.0 means fully opaque and
0.0 means fully transparent.
Page 53 of 82
Android Project
android:duration="4000" />
fromDegreesRotation
o offset to apply at the start of the animation.
toDegreesRotation
o offset to apply at the end of the animation.
pivotX
Page 54 of 82
Android Project
o The X coordinate of the point about which the
object is
being rotated, specified as an absolute number where 0 is
the left edge.
pivotYo The Y coordinate of the point about which the object is
being rotated, specified as an absolute number where 0 is
the top edge.
Translate Animation
TranslateAnimation Lets you move the selected View around the
screen (although it will only be drawn within its original
bounds).
<translate
xmlns:android="http://schemas.android.com/apk/res/androi"
android:fromXDelta="200%"
android:toXDelta="0%"
android:fromYDelta="200%"
android:toYDelta="0%"
android:duration="3000"
android:zAdjustment="top" />
fromXDelta
Change in X coordinate to apply at the start of the
animation.
toXDelta
Page 55 of 82
Android Project
Change in X coordinate to apply at the end of the
animation.
fromYDelta
Change in Y coordinate to apply at the start of the
animation to.
Ydelta
Change in Y coordinate to apply at the end of the
animation .
Scale Animation
ScaleAnimation Allows you to zoom in to or out from the
selected View.
<scale xmlns:android="http://schemas.android.com/apk/res/android"
android:fromXScale="4"
android:toXScale="1"
android:fromYScale="3"
android:toYScale="1"
android:pivotX="50%"
android:pivotY="50%"
android:duration="4000" />
fromX
Horizontal scaling factor to apply at the start of the animation
toX
Page 56 of 82
Android Project
Horizontal scaling factor to apply at the end of the
animation
QUIZ APPLICATION
INTRODUCTION--We are Quizter, a project created to make learning fun. Our vision was to create
a cross-platform application that combines elements such as gaming, quizzing
and competition based on content that the user is interested to learn. The
application should give users an easy way to repeat curriculum, learn about new
topics and work as a place to look for references and tips. The application
should be easy to use and pause making it easy to work with at any time in
any place.
Overview--In this report, we will present the application called Crack Qizzed. At first, we
will present the theoretical concepts relevant to the learning in technological
environment. Later, the functionality and visual layout of the application are
explained and argued. The findings from the project are being analyzed using
the knowledge we acquired during the development of the application.
Project Goals
The goal of the project was to have a functional running prototype of the application and
fulfil the requirements of the course.
Android Project
Words and concepts--Here are the words and concepts that are not familiar to the reader, or which
might produce confusions with their special use. The assumption is
that the readers are familiar with mobile applications and operating systems.
In addition, the notation used in the document can be defined in this section.
The example of this is shown in table.
Table 1 Notation used in the document.
Quiz
Quiz modes
--
APPROACH-Aims
Objectives
This project is connected with the course Android - Development of mobile
information systems and services at the AL-FALAH UNIVERSITY. Our
project started in March 2016 and will finish in April 2016.
As mentioned in our aims our goal was to create a new aspect for learning
school curriculum through, and increase the students motivation through
mobile technology.
During this period we will develop a cross platform prototype for this quiz app,
named Quiz app. The prototype will be developed in the software ECLIPSE
MARS 1. .
Page 58 of 82
Android Project
Making a project-----In eclipse we are going to making a project and thats named is Crack Quizzed and
screenshort is givin below..
Screen short--Step 1-
Step 2-
Page 59 of 82
Android Project
Step 3-
Page 60 of 82
Android Project
Step 4
Step 5--
Programming--Page 61 of 82
Android Project
ImageButton img;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main)
img = (ImageButton) findViewById(R.id.imageButton1);
img.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
Intent k = new Intent(MainActivity.this,Start.class);
startActivity(k);
}
});
Page 62 of 82
Android Project
}
Content ActivityPage 63 of 82
Android Project
Java file
package com.exam.crackquizzed;
import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.ImageButton;
btn1.setOnClickListener(new OnClickListener() {
Page 64 of 82
Android Project
@Override
public void onClick(View v) {
Intent n= new Intent(Content.this,Java1.class);
startActivity(n);
}
});
btn2.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
Intent n= new Intent(Content.this,Html1.class);
startActivity(n);
}
});
btn3.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
Intent n= new Intent(Content.this,Php1.class);
startActivity(n);
Page 65 of 82
Android Project
}
});
btn4.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
Intent n= new Intent(Content.this,Andr1.class);
startActivity(n);
}
});
}
}
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1.0"
Page 66 of 82
Android Project
android:orientation="horizontal" >
<ImageButton
android:id="@+id/button1"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@drawable/java"
android:layout_weight="1.0"
/>
<ImageButton
android:id="@+id/button2"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@drawable/html"
android:layout_weight="1.0"
/>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1.0"
Page 67 of 82
Android Project
android:orientation="horizontal" >
<ImageButton
android:id="@+id/button3"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@drawable/php"
android:layout_weight="1.0"
/>
<ImageButton
android:id="@+id/button4"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@drawable/and"
android:layout_weight="1.0"
/>
</LinearLayout>
</LinearLayout>
Android Project
package com.exam.crackquizzed;
import android.app.Activity;
import android.content.Intent;
import android.graphics.Color;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.RadioButton;
import android.widget.Toast;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_andr1);
b1=(RadioButton) findViewById(R.id.radio0);
b2=(RadioButton) findViewById(R.id.radio1);
b3=(RadioButton) findViewById(R.id.radio2);
b4=(RadioButton) findViewById(R.id.radio3);
Back = (Button) findViewById(R.id.button1);
Page 69 of 82
Android Project
Answer = (Button) findViewById(R.id.button2);
Next = (Button) findViewById(R.id.button3);
Back.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
//
Intent n= new Intent(Andr1.this,Content.class);
startActivity(n);
}
});
Answer.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
Toast.makeText(getBaseContext(), "All of these are
components of the APK " , Toast.LENGTH_SHORT).show();
}
});
Next.setOnClickListener(new OnClickListener() {
@Override
Page 70 of 82
Android Project
public void onClick(View v) {
// TODO Auto-generated method stub
Intent n= new Intent(Andr1.this,Andr2.class);
startActivity(n);
}
});
}
Android Project
case R.id.radio1:
if(checked){
b2.setBackgroundColor(Color.GREEN);
b1.setEnabled(false);
b3.setEnabled(false);
b2.setBackgroundColor(Color.GREEN);
b2.setEnabled(true);
}
else{
b2.setEnabled(false);
}
break;
case R.id.radio2:
if(checked){
b1.setEnabled(false);
b2.setBackgroundColor(Color.GREEN);
b4.setEnabled(false);
b3.setBackgroundColor(Color.RED);
b3.setEnabled(true);
}
else{
b3.setEnabled(false);
}
break;
Page 72 of 82
Android Project
case R.id.radio3:
if(checked){
b1.setEnabled(false);
b3.setEnabled(false);
b2.setBackgroundColor(Color.GREEN);
b4.setBackgroundColor(Color.RED);
b4.setEnabled(true);
}
else{
b4.setEnabled(false);
}
break;
}
}
}
Android Project
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
android:background="@drawable/back"
tools:context="com.example.successquizapp.Gk1Activity" >
<TextView
android:id="@+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:text="1.Which of the following are not a component of an APK
file?"
android:textAppearance="?android:attr/textAppearanceLarge" />
<Button
android:id="@+id/button1"
android:layout_width="wrap_content"
android:layout_height="50dp"
android:layout_alignLeft="@+id/textView1"
android:layout_alignParentBottom="true"
android:layout_marginBottom="59dp"
android:background="@drawable/num_back"
android:text="Back" />
Page 74 of 82
Android Project
<Button
android:id="@+id/button2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBaseline="@+id/button1"
android:layout_alignBottom="@+id/button1"
android:layout_centerHorizontal="true"
android:background="@drawable/enter_back"
android:text="Answer" />
<Button
android:id="@+id/button3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_alignTop="@+id/button1"
android:background="@drawable/num_back"
android:text="Next" />
<RadioGroup
android:id="@+id/radioGroup1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="@+id/textView1"
android:layout_below="@+id/textView1"
Page 75 of 82
Android Project
android:layout_marginTop="14dp" >
<RadioButton
android:id="@+id/radio0"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="@+id/textView1"
android:layout_alignTop="@+id/radioGroup1"
android:layout_marginTop="20dp"
android:onClick="fun"
android:text="Resources"
android:textSize="20dp" />
<RadioButton
android:id="@+id/radio1"
android:layout_width="209dp"
android:layout_height="wrap_content"
android:layout_alignLeft="@+id/radio3"
android:layout_below="@+id/radio3"
android:onClick="fun"
android:text="All of these are components of the APK "
android:textSize="20dp" /
<RadioButton
android:id="@+id/radio2"
Page 76 of 82
Android Project
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="@+id/radio0"
android:layout_below="@+id/radio0"
android:onClick="fun"
android:text="Native Libraries"
android:textSize="20dp" />
<RadioButton
android:id="@+id/radio3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="@+id/radio2"
android:layout_below="@+id/radio2"
android:onClick="fun"
android:text="Dalvik executable"
android:textSize="20dp" />
</RadioGroup>
</RelativeLayout>
Page 77 of 82
Android Project
Step 2-
Page 78 of 82
Android Project
Step 3-
Step4--
Page 79 of 82
Android Project
Step5-
Step6--
Page 80 of 82
Android Project
********************************************
*
Page 81 of 82