SlideShare ist ein Scribd-Unternehmen logo
1 von 82
Advance UI : Development and
Design
Rakesh Kumar Jha
M. Tech, MBA
Delivery Manager
Android Windowing System
What is Android windowing system
Overview
Architecture
Components
Development
Code
Q & A
What is Android windowing system
 In computing, a windowing
system (or window system) is a type
of graphical user interface (GUI) which
implements the WIMP (windows, icons,
menus, pointer) paradigm for a user
interface.
What is Android windowing system
Most popular windowing systems are X11
and Wayland
Most popular widget toolkits
are GTK+/Clutter and Qt
Most popular desktop environments
are GNOME and the KDE Software
Compilation
X Window
The X Window System (sometimes referred to
as "X" or as "XWindows") is an open, cross-
platform, client/server system for managing a
windowed graphical user interface in a
distributed network.
 is a windowing system for bitmap displays,
common on UNIX-like computer operating
systems.
System Architecture
System Architecture
System Architecture
Building Blocks
There are more, but we focus on
SurfaceManager
WindowManager
ActivityManager
SurfaceManager
frameworks/base/libs/surfaceflinger/
a.k.a SurfaceFlinger
Allocate surfaces. Backed by shmem/pmem/?
Composite surfaces
SurfaceManager
 It is used for compositing window manager
with off-screen buffering.
Off-screen buffering means you cant directly
draw into the screen, but your drawings go to
the off-screen buffer.
There it is combined with other drawings and
form the final screen the user will see.
This off screen buffer is the reason behind the
transparency of windows.
WindowManager
frameworks/base/services/java/com/android/
server/WindowManagerService.java
(Ask SurfaceManager to) create/layout
surfaces on behalf of the clients
Dispatch input events to clients
Transition animation
WindowManagerPolicy
WindowManager
The interface that apps use to talk to the
window manager.
Use Context.getSystemService(Context.WIND
OW_SERVICE) to get one of these.
WindowManager
Each window manager instance is bound to a
particular Display.
To obtain a WindowManager for a different
display, use createDisplayContext(Display) to
obtain a Context for that display, then
use Context.getSystemService(Context.WINDO
W_SERVICE) to get the WindowManager.
ActivityManager
frameworks/base/services/java/com/android/
server/am/
Manage lifecycles of activities
Manage stacking of activities
Dispatch intents
Spawn processes
ActivityManager
Interact with the overall activities running in the
system.
Information you can retrieve about the available
memory
Information you can retrieve about any processes
that are in an error condition.
Information you can retrieve about a running
process.
ActivityManager.MemoryInfo,
ActivityManager.RunningAppProcessInfo
An activity has one or more windows (e.g.
dialogs)
A window has one or more surfaces (e.g.
surface views)
However, in window manager, a window is
called a session
A surface is called a window
How Android Draws Views?
• When an Activity receives focus, it will be
requested to draw its layout.
• The Android framework will handle the
procedure for drawing, but the Activity must
provide the root node of its layout hierarchy.
How Android Draws Views?
• When an Activity receives focus, it will be
requested to draw its layout.
• The Android framework will handle the
procedure for drawing, but the Activity must
provide the root node of its layout hierarchy.
• Drawing the layout is a two pass process: a
measure pass and a layout pass.
Handling Gestures
Handling Gestures
Some examples of common multi-touch gestures
and actions you might use include:
Pinch to zoom in, spread to zoom out.
Basic dragging in order to move, adjust, scroll,
and position.
Flick to jump to the next screen or scroll extra
fast.
Tap and hold to open an item or context menu.
Multi-finger drag often scrolls faster!
Handling Gestures
Handling multi touch gesture
Detecting common gesture
Managing touch event
Animating a scroll gesture
Tracking movement
Dragging & scalling
Handling Gestures
Android provides special types of touch screen
events such as pinch , double tap, scrolls , long
presses and flinch. These are all known as
gestures.
Handling Gestures
Android provides GestureDetector class to
receive motion events and tell us that these
events correspond to gestures or not.
Handling Gestures
To use it , you need to create an object of
GestureDetector and then extend another
class with
GestureDetector.SimpleOnGestureListener to
act as a listener and override some methods.
Handling Gestures
GestureDetector myG;
myG = new GestureDetector(this,new Gesture());
class Gesture extends GestureDetector.SimpleOnGestureListener{
public boolean onSingleTapUp(MotionEvent ev) {
}
public void onLongPress(MotionEvent ev) {
}
public boolean onScroll(MotionEvent e1, MotionEvent e2, float distanceX,
float distanceY) {
}
public boolean onFling(MotionEvent e1, MotionEvent e2, float velocityX,
float velocityY) {
}
}
}
Handling Pinch Gesture
Android provides ScaleGestureDetector class
to handle gestures like pinch e.t.c. In order to
use it , you need to instantiate an object of
this class. Its syntax is as follow: -
ScaleGestureDetector SGD; SGD = new ScaleGestureDetector(this,new
ScaleListener());
Handling Pinch Gesture
 We have to define the event listener and override a function OnTouchEvent to
make it working.
public boolean onTouchEvent(MotionEvent ev) {
SGD.onTouchEvent(ev);
return true;
}
private class ScaleListener extends
ScaleGestureDetector.SimpleOnScaleGestureListener {
@Override
public boolean onScale(ScaleGestureDetector detector) {
float scale = detector.getScaleFactor();
return true;
}
}
Handling Pinch Gesture
Apart from the pinch gestures , there are other
methods avaialible that notify more about touch
events. They are listed below:
1 getEventTime()
This method get the event time of the current event being processed..
2 getFocusX()
This method get the X coordinate of the current gesture's focal point.
3 getFocusY()
This method get the Y coordinate of the current gesture's focal point.
4 getTimeDelta()
This method return the time difference in milliseconds between the previous accepted scaling event and the
current scaling event.
5 isInProgress()
This method returns true if a scale gesture is in progress..
6 onTouchEvent(MotionEvent event)
This method accepts MotionEvents and dispatches events when appropriate.
Handling Pinch Gesture
Use of ScaleGestureDetector class.
It creates a basic application that allows you to
zoom in and out through pinch.
Animation
Animation in Android
• Animation in android is possible from many
ways.
• making animation called tweened animation.
Animation in Android
• Animation in android is possible from many
ways.
• making animation called tweened animation.
Tween Animation
• Tween Animation takes some parameters such
as start value , end value, size , time duration ,
rotation angle e.t.c and perform the required
animation on that object.
Tween Animation
• In order to perform animation in android , call
a static function loadAnimation() of the class
AnimationUtils.
Animation animation =
AnimationUtils.loadAnimation(getApplicationContext(),
R.anim.myanimation);
second parameter, it is the name of the our animation xml file.
Sr.No Method & Description
1 start()
This method starts the animation.
2 setDuration(long duration)
This method sets the duration of an animation.
3 getDuration()
This method gets the duration which is set by above
method
4 end()
This method ends the animation.
5 cancel()
This method cancels the animation.
Tween Animation
Tween Animation
ImageView image1 = (ImageView)findViewById(R.id.imageView1);
image.startAnimation(animation);
Zoom in animation
• To perform a zoom in animation , create an
XML file under anim folder under res
directory, and put zoom xml code.
<set xmlns:android="http://schemas.android.com/apk/res/android"> <scale
xmlns:android="http://schemas.android.com/apk/res/android"
android:fromXScale="0.5" android:toXScale="3.0" android:fromYScale="0.5"
android:toYScale="3.0" android:duration="5000" android:pivotX="50%"
android:pivotY="50%" > </scale> </set>
Zoom in animation
• The
parameter fromXScale and fromYScale define
s the start point and the
parameters toXScale andtoYScale defines the
end point.
• The duration defines the time of animation
and the pivotX, pivotYdefines the center from
where the animation would start.
Custom UI Views Architecture
• Android offers a sophisticated and powerful
componentized model for building your UI, based
on the fundamental layout classes: View
and ViewGroup.
• A partial list of available widgets
includes Button, TextView,
EditText, ListView, CheckBox,
RadioButton, Gallery, Spinner, and the more
special-
purpose AutoCompleteTextView, ImageSwitcher,
and TextSwitcher.
• Among the layouts available
are LinearLayout, FrameLayout, RelativeLayout,
and others
• If none of the prebuilt widgets or layouts
meets your needs, you can create your own
View subclass.
View Hierarchy Design
• Sometimes your application's layout can slow
down your application. To help debug issues in
your layout, the Android SDK provides the
Hierarchy Viewer and lint tools.
View Hierarchy Design
• The Hierarchy Viewer application allows you
to debug and optimize your user interface
• It provides a visual representation of the
layout's View hierarchy
View Hierarchy Design
• Android lint is a static code scanning tool that
helps you optimize the layouts and layout
hierarchies of your applications, as well as
detect other common coding problems.
Using Hierarchy Viewer
• Connect your device or launch an emulator. To
preserve security, Hierarchy Viewer can only connect to
devices running a developer version of the Android
system.
• If you have not done so already, install the application
you want to work with.
• Run the application, and ensure that its UI is visible.
• From a terminal, launch hierarchyviewer from
the <sdk>/tools/ directory.
• Window will launched with device list
• Select apps name(packagename) and perform
operaion.
Using Hierarchy Viewer
• The View Hierarchy window displays the View
objects that form the UI of the Activity that is
running on your device or emulator.
• You should see four panes:-
– Tree View:
– Tree Overview,
– Layout View,
– Properties View
Using Hierarchy Viewer
• When the UI of the current Activity changes,
the View Hierarchy window is not
automatically updated.
• To update it, click Load View Hierarchy at the
top of the window.
Working with an individual View in
Tree View
• Each node in Tree View represents a single
View. Some information is always visible.
• Starting at the top of the node, you see the
following:
Working with an individual View in
Tree View
1. View class: The View object's class.
2. View object address: A pointer to View
object.
3. View object ID: The value of
the android:id attribute.
4. Performance indicators:
1. Green: Fastest, 50% faster than view object
2. Yellow : slower 50% of all the View objects
3. Red : slowest one in the tree
Working with an individual View in
Tree View
5. View index: The zero-based index of the View
in its parent View. If it is the only child, this is
0.
Using lint to Optimize Your UI
• The Android lint tool lets you analyze the XML
files that define your application's UI to find
inefficiencies in the view hierarchy.
• Note: The Android layoutopt tool has been
replaced by the lint tool beginning in ADT and
SDK Tools revision 16. The lint tool reports UI
layout performance issues in a similar way
as layoutopt, and detects additional problems.
Using lint to Optimize Your UI
• Improving Your Code with lint
• The Android SDK provides a code scanning
tool called lint that can help you to easily
identify and correct problems with the
structural quality of your code, without having
to execute the app or write any test cases.
Using lint to Optimize Your UI
• The lint tool checks your Android project
source files for potential bugs and
optimization improvements for correctness,
security, performance, usability, accessibility,
and internationalization.
• You can run lint from the command-line or
from the Eclipse environment.
Running lint from Eclipse
If the ADT Plugin is installed in your Eclipse
environment, the lint tool runs automatically
when you perform one of these actions:
Export an APK
Edit and save an XML source file in your
Android project (such as a manifest or layout
file)
Use the layout editor in Eclipse to make
changes
Running lint from the Command-Line
• To run lint against a list of files in a project
directory:
int [flags] <project directory>
lint --check MissingPrefix myproject
Configuring lint
You can configure lint checking at different
levels:
Globally, for all projects
Per project
Per file
Per Java class or method (by using
the @SuppressLint annotation), or per XML
element (by using the tools:ignoreattribute.
Configuring lint in Eclipse
You can configure global, project-specific, and
file-specific settings for lint from the Eclipse user
interface.
Global preferences
• Open Window > Preferences > Android > Lint
Error Checking.
• Specify your preferences and click OK.
Project and file-specific preferences
• Run the lint tool on your project by right-
clicking on your project folder in the Package
Explorer and selecting Android Tools > Run
Lint: Check for Common Errors.
• From the Lint Warnings view, use the toolbar
options to configure lint preferences for
individual projects and files in Eclipse.
Project and file-specific preferences
The options you can select include:
• Suppress this error with an annotation/attribute - If the
issue appears in a Java class, the lint tool adds
a@SuppressLint annotation to the method where the issue
was detected. If the issue appears in an .xml file, lintinserts
a tools:ignore attribute to disable checking for the lint issue
in this file.
• Ignore in this file - Disables checking for this lint issue in
this file.
• Ignore in this project - Disables checking for this lint issue
in this project.
• Always ignore - Disables checking for this lint issue globally
for all projects.
Configuring the lint file
You can specify your lint checking preferences
in the lint.xml file.
 If you are creating this file manually, place it
in the root directory of your Android project.
If you are configuring lint preferences in
Eclipse, the lint.xml file is automatically
created and added to your Android project for
you.
Sample lint.xml file
<?xml version="1.0" encoding="UTF-8"?>
<lint>
<!-- Disable the given check in this project -->
<issue id="IconMissingDensityFolder" severity="ignore" />
<!-- Ignore the ObsoleteLayoutParam issue in the specified files -->
<issue id="ObsoleteLayoutParam">
<ignore path="res/layout/activation.xml" />
<ignore path="res/layout-xlarge/activation.xml" />
</issue>
<!-- Ignore the UselessLeaf issue in the specified file -->
<issue id="UselessLeaf">
<ignore path="res/layout/main.xml" />
</issue>
<!-- Change the severity of hardcoded strings to "error" -->
<issue id="HardcodedText" severity="error" />
</lint>
Event Propagation and Event Handling
in Views
For each application, a ViewRootImpl object is
created to handle communications with the
remote system WindowManagerService object.
The communication is through a Linux pipe which
is encapsulated in an InputChannel object
(mInputChannel field in class ViewRootImpl).
TheViewRootImpl object also registers an
instance of InputEventReceiver when the
first View object is registered with it.
Event Propagation and Event Handling
in Views
public void setView(View view, ...) {
...
mInputEventReceiver = new WindowInputEventReceiver(mInputChannel,
Looper.myLooper());
...
}
The constructor of
class WindowInputEventReceiver (class WindowManagerService extends
from classInputEventReceiver) calls a native methond nativeInit(...):
Event Propagation and Event Handling
in Views
58 public InputEventReceiver(InputChannel inputChannel, Looper looper) {
...
66 mInputChannel = inputChannel;
67 mMessageQueue = looper.getQueue();
68 mReceiverPtr = nativeInit(this, inputChannel, mMessageQueue);
...
71 }
Event Propagation and Event Handling
in Views
Three parameters are passed to the native function nativeInit:
1) The receiver object itself;
2) TheInputChannel object passed from the ViewRootImpl object.
3) The main message queue (an object of class MessageQueue) of the
application.
Event Propagation and Event Handling
in Views
227 static jint nativeInit(JNIEnv* env, jclass clazz, jobject receiverObj,
228 jobject inputChannelObj, jobject messageQueueObj) {
229 sp<InputChannel> inputChannel =
android_view_InputChannel_getInputChannel(env,
230 inputChannelObj);
...
236 sp<MessageQueue> messageQueue =
android_os_MessageQueue_getMessageQueue(env, messageQueueObj);
...
242 sp<NativeInputEventReceiver> receiver = new
NativeInputEventReceiver(env,
243 receiverObj, inputChannel, messageQueue);
244 status_t status = receiver->initialize();
...
254 }
Event Propagation and Event Handling
in Views
Included in the event listener interfaces are the
following callback methods:-
onClick()
onLongClick()
onFocusChange()
onKey()
onTouch()
onCreateContextMenu()
Event Propagation and Event Handling
in Views
Included in the event listener interfaces are the
following callback methods:-
onClick()
onLongClick()
onFocusChange()
onKey()
onTouch()
onCreateContextMenu()
Localisation and Accessibility
• An android application can run on many
devices in many different regions.
• In order to make your application more
interactive, your application should handle
text,numbers,files e.t.c in ways appropriate to
the locales where your application will be
used.
Localizing Strings
• In order to localize the strings used in your
application , make a new folder under res with
name ofvalues-local where local would be the
replaced with the region.
• For example, in the case of italy, the values-
it folder would be made under res. It is shown
in the image below:
Localizing Strings
Localizing Strings
• Once that folder is made, copy
the strings.xmlfrom default folder to the
folder you have created. And change its
contents. For example, i have changed the
value of hello_world string.
Localizing Strings
• ITALY, RES/VALUES-IT/STRINGS.XML
<;?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="hello_world">Ciao mondo!</string>
</resources>
Localizing Strings
• Chinese, RES/VALUES-zh/STRINGS.XML
<;?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="hello_world">Hola Mundo!</string>
</resources>
Localizing Strings
• FRENCH, RES/VALUES-FR/STRINGS.XML
<;?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="hello_world">Bonjour le monde !</string>
</resources>

Weitere ähnliche Inhalte

Was ist angesagt?

Learning, Analyzing and Protecting Android with TOMOYO Linux (JLS2009)
Learning, Analyzing and Protecting Android with TOMOYO Linux (JLS2009)Learning, Analyzing and Protecting Android with TOMOYO Linux (JLS2009)
Learning, Analyzing and Protecting Android with TOMOYO Linux (JLS2009)Toshiharu Harada, Ph.D
 
Developing for Industrial IoT with Linux OS on DragonBoard™ 410c: Session 3
Developing for Industrial IoT with Linux OS on DragonBoard™ 410c: Session 3Developing for Industrial IoT with Linux OS on DragonBoard™ 410c: Session 3
Developing for Industrial IoT with Linux OS on DragonBoard™ 410c: Session 3Qualcomm Developer Network
 
Android village @nullcon 2012
Android village @nullcon 2012 Android village @nullcon 2012
Android village @nullcon 2012 hakersinfo
 
Inside Android's UI
Inside Android's UIInside Android's UI
Inside Android's UIOpersys inc.
 
Android complete basic Guide
Android complete basic GuideAndroid complete basic Guide
Android complete basic GuideAKASH SINGH
 
Android Meetup, Илья Лёвин
Android Meetup, Илья ЛёвинAndroid Meetup, Илья Лёвин
Android Meetup, Илья ЛёвинGDG Saint Petersburg
 
Introduction to Android by Demian Neidetcher
Introduction to Android by Demian NeidetcherIntroduction to Android by Demian Neidetcher
Introduction to Android by Demian NeidetcherMatthew McCullough
 
Android terminologies
Android terminologiesAndroid terminologies
Android terminologiesjerry vasoya
 
Developing for Industrial IoT with Linux OS on DragonBoard™ 410c: Session 4
Developing for Industrial IoT with Linux OS on DragonBoard™ 410c: Session 4Developing for Industrial IoT with Linux OS on DragonBoard™ 410c: Session 4
Developing for Industrial IoT with Linux OS on DragonBoard™ 410c: Session 4Qualcomm Developer Network
 
[Webinar] An Introduction to the Yocto Embedded Framework
[Webinar] An Introduction to the Yocto Embedded Framework[Webinar] An Introduction to the Yocto Embedded Framework
[Webinar] An Introduction to the Yocto Embedded FrameworkICS
 
Android Development...The 20,000-Foot View
Android Development...The 20,000-Foot ViewAndroid Development...The 20,000-Foot View
Android Development...The 20,000-Foot ViewCommonsWare
 
Q4.11: Porting Android to new Platforms
Q4.11: Porting Android to new PlatformsQ4.11: Porting Android to new Platforms
Q4.11: Porting Android to new PlatformsLinaro
 
Dalvik Vm &amp; Jit
Dalvik Vm &amp; JitDalvik Vm &amp; Jit
Dalvik Vm &amp; JitAnkit Somani
 
Understanding the Android System Server
Understanding the Android System ServerUnderstanding the Android System Server
Understanding the Android System ServerOpersys inc.
 
Skype testing overview
Skype testing overviewSkype testing overview
Skype testing overviewQA Club Kiev
 

Was ist angesagt? (20)

Learning, Analyzing and Protecting Android with TOMOYO Linux (JLS2009)
Learning, Analyzing and Protecting Android with TOMOYO Linux (JLS2009)Learning, Analyzing and Protecting Android with TOMOYO Linux (JLS2009)
Learning, Analyzing and Protecting Android with TOMOYO Linux (JLS2009)
 
Developing for Industrial IoT with Linux OS on DragonBoard™ 410c: Session 3
Developing for Industrial IoT with Linux OS on DragonBoard™ 410c: Session 3Developing for Industrial IoT with Linux OS on DragonBoard™ 410c: Session 3
Developing for Industrial IoT with Linux OS on DragonBoard™ 410c: Session 3
 
Android Internals
Android InternalsAndroid Internals
Android Internals
 
Android village @nullcon 2012
Android village @nullcon 2012 Android village @nullcon 2012
Android village @nullcon 2012
 
Inside Android's UI
Inside Android's UIInside Android's UI
Inside Android's UI
 
Balancing Power & Performance Webinar
Balancing Power & Performance WebinarBalancing Power & Performance Webinar
Balancing Power & Performance Webinar
 
TOMOYO Linux on Android
TOMOYO Linux on AndroidTOMOYO Linux on Android
TOMOYO Linux on Android
 
Android complete basic Guide
Android complete basic GuideAndroid complete basic Guide
Android complete basic Guide
 
Android Meetup, Илья Лёвин
Android Meetup, Илья ЛёвинAndroid Meetup, Илья Лёвин
Android Meetup, Илья Лёвин
 
Introduction to Android by Demian Neidetcher
Introduction to Android by Demian NeidetcherIntroduction to Android by Demian Neidetcher
Introduction to Android by Demian Neidetcher
 
Android Programming
Android ProgrammingAndroid Programming
Android Programming
 
Android terminologies
Android terminologiesAndroid terminologies
Android terminologies
 
Developing for Industrial IoT with Linux OS on DragonBoard™ 410c: Session 4
Developing for Industrial IoT with Linux OS on DragonBoard™ 410c: Session 4Developing for Industrial IoT with Linux OS on DragonBoard™ 410c: Session 4
Developing for Industrial IoT with Linux OS on DragonBoard™ 410c: Session 4
 
[Webinar] An Introduction to the Yocto Embedded Framework
[Webinar] An Introduction to the Yocto Embedded Framework[Webinar] An Introduction to the Yocto Embedded Framework
[Webinar] An Introduction to the Yocto Embedded Framework
 
Android Development...The 20,000-Foot View
Android Development...The 20,000-Foot ViewAndroid Development...The 20,000-Foot View
Android Development...The 20,000-Foot View
 
Q4.11: Porting Android to new Platforms
Q4.11: Porting Android to new PlatformsQ4.11: Porting Android to new Platforms
Q4.11: Porting Android to new Platforms
 
Dalvik Vm &amp; Jit
Dalvik Vm &amp; JitDalvik Vm &amp; Jit
Dalvik Vm &amp; Jit
 
Understanding the Android System Server
Understanding the Android System ServerUnderstanding the Android System Server
Understanding the Android System Server
 
Low Level View of Android System Architecture
Low Level View of Android System ArchitectureLow Level View of Android System Architecture
Low Level View of Android System Architecture
 
Skype testing overview
Skype testing overviewSkype testing overview
Skype testing overview
 

Andere mochten auch

Principles of User Interface Design
Principles of User Interface DesignPrinciples of User Interface Design
Principles of User Interface DesignKANKIPATI KISHORE
 
Android Layout模組化介紹
Android Layout模組化介紹Android Layout模組化介紹
Android Layout模組化介紹Chris Jeng
 
User Interface Design @iRajLal
User Interface Design @iRajLalUser Interface Design @iRajLal
User Interface Design @iRajLalRaj Lal
 
UX UI - Principles and Best Practices 2014-2015
UX UI - Principles and Best Practices 2014-2015UX UI - Principles and Best Practices 2014-2015
UX UI - Principles and Best Practices 2014-2015Harsh Wardhan Dave
 
15 Quotes To Nurture Your Creative Soul!
15 Quotes To Nurture Your Creative Soul!15 Quotes To Nurture Your Creative Soul!
15 Quotes To Nurture Your Creative Soul!DesignMantic
 

Andere mochten auch (7)

Principles of User Interface Design
Principles of User Interface DesignPrinciples of User Interface Design
Principles of User Interface Design
 
Android Layout模組化介紹
Android Layout模組化介紹Android Layout模組化介紹
Android Layout模組化介紹
 
Advance Android Layout Walkthrough
Advance Android Layout WalkthroughAdvance Android Layout Walkthrough
Advance Android Layout Walkthrough
 
User Interface Design @iRajLal
User Interface Design @iRajLalUser Interface Design @iRajLal
User Interface Design @iRajLal
 
UX UI - Principles and Best Practices 2014-2015
UX UI - Principles and Best Practices 2014-2015UX UI - Principles and Best Practices 2014-2015
UX UI - Principles and Best Practices 2014-2015
 
UX Best Practices
UX Best PracticesUX Best Practices
UX Best Practices
 
15 Quotes To Nurture Your Creative Soul!
15 Quotes To Nurture Your Creative Soul!15 Quotes To Nurture Your Creative Soul!
15 Quotes To Nurture Your Creative Soul!
 

Ähnlich wie Advance ui development and design

Android Jumpstart Jfokus
Android Jumpstart JfokusAndroid Jumpstart Jfokus
Android Jumpstart JfokusLars Vogel
 
Android Tutorial
Android TutorialAndroid Tutorial
Android TutorialFun2Do Labs
 
ANDROID LAB MANUAL.doc
ANDROID LAB MANUAL.docANDROID LAB MANUAL.doc
ANDROID LAB MANUAL.docPalakjaiswal43
 
Android Tutorial For Beginners Part-1
Android Tutorial For Beginners Part-1Android Tutorial For Beginners Part-1
Android Tutorial For Beginners Part-1Amit Saxena
 
[PBO] Pertemuan 12 - Pemrograman Android
[PBO] Pertemuan 12 - Pemrograman Android[PBO] Pertemuan 12 - Pemrograman Android
[PBO] Pertemuan 12 - Pemrograman Androidrizki adam kurniawan
 
Everything About Android - Itvedant, Thane | Mumbai | Navi Mumbai
Everything About Android - Itvedant, Thane | Mumbai | Navi Mumbai Everything About Android - Itvedant, Thane | Mumbai | Navi Mumbai
Everything About Android - Itvedant, Thane | Mumbai | Navi Mumbai Itvedant
 
Synapseindia android application development tutorial
Synapseindia android application development tutorialSynapseindia android application development tutorial
Synapseindia android application development tutorialSynapseindiappsdevelopment
 
Synapseindia android apps development tutorial
Synapseindia android apps  development tutorialSynapseindia android apps  development tutorial
Synapseindia android apps development tutorialSynapseindiappsdevelopment
 
Build Mobile Application In Android
Build Mobile Application In AndroidBuild Mobile Application In Android
Build Mobile Application In Androiddnnddane
 
Android apps development
Android apps developmentAndroid apps development
Android apps developmentMonir Zzaman
 
iOS for C# Developers - DevConnections Talk
iOS for C# Developers - DevConnections TalkiOS for C# Developers - DevConnections Talk
iOS for C# Developers - DevConnections TalkMiguel de Icaza
 
Workshop Android for Java Developers
Workshop Android for Java DevelopersWorkshop Android for Java Developers
Workshop Android for Java Developersmhant
 
Android Apps Development Basic
Android Apps Development BasicAndroid Apps Development Basic
Android Apps Development BasicMonir Zzaman
 
OS in mobile devices [Android]
OS in mobile devices [Android]OS in mobile devices [Android]
OS in mobile devices [Android]Yatharth Aggarwal
 

Ähnlich wie Advance ui development and design (20)

Custom components
Custom componentsCustom components
Custom components
 
Android
AndroidAndroid
Android
 
Designing Apps for the Motorola XOOM
Designing Apps for the Motorola XOOM Designing Apps for the Motorola XOOM
Designing Apps for the Motorola XOOM
 
Android Jumpstart Jfokus
Android Jumpstart JfokusAndroid Jumpstart Jfokus
Android Jumpstart Jfokus
 
Android Tutorial
Android TutorialAndroid Tutorial
Android Tutorial
 
ANDROID LAB MANUAL.doc
ANDROID LAB MANUAL.docANDROID LAB MANUAL.doc
ANDROID LAB MANUAL.doc
 
Android Tutorial For Beginners Part-1
Android Tutorial For Beginners Part-1Android Tutorial For Beginners Part-1
Android Tutorial For Beginners Part-1
 
[PBO] Pertemuan 12 - Pemrograman Android
[PBO] Pertemuan 12 - Pemrograman Android[PBO] Pertemuan 12 - Pemrograman Android
[PBO] Pertemuan 12 - Pemrograman Android
 
Android101
Android101Android101
Android101
 
Everything About Android - Itvedant, Thane | Mumbai | Navi Mumbai
Everything About Android - Itvedant, Thane | Mumbai | Navi Mumbai Everything About Android - Itvedant, Thane | Mumbai | Navi Mumbai
Everything About Android - Itvedant, Thane | Mumbai | Navi Mumbai
 
Synapseindia android application development tutorial
Synapseindia android application development tutorialSynapseindia android application development tutorial
Synapseindia android application development tutorial
 
Synapseindia android apps development tutorial
Synapseindia android apps  development tutorialSynapseindia android apps  development tutorial
Synapseindia android apps development tutorial
 
Build Mobile Application In Android
Build Mobile Application In AndroidBuild Mobile Application In Android
Build Mobile Application In Android
 
Unit I- ANDROID OVERVIEW.ppt
Unit I- ANDROID OVERVIEW.pptUnit I- ANDROID OVERVIEW.ppt
Unit I- ANDROID OVERVIEW.ppt
 
Android apps development
Android apps developmentAndroid apps development
Android apps development
 
JAVA (UNIT 5)
JAVA (UNIT 5)JAVA (UNIT 5)
JAVA (UNIT 5)
 
iOS for C# Developers - DevConnections Talk
iOS for C# Developers - DevConnections TalkiOS for C# Developers - DevConnections Talk
iOS for C# Developers - DevConnections Talk
 
Workshop Android for Java Developers
Workshop Android for Java DevelopersWorkshop Android for Java Developers
Workshop Android for Java Developers
 
Android Apps Development Basic
Android Apps Development BasicAndroid Apps Development Basic
Android Apps Development Basic
 
OS in mobile devices [Android]
OS in mobile devices [Android]OS in mobile devices [Android]
OS in mobile devices [Android]
 

Mehr von Rakesh Jha

Whitep paper on Emerging java and .net technology and critical trends
Whitep paper on Emerging java and .net technology and critical trendsWhitep paper on Emerging java and .net technology and critical trends
Whitep paper on Emerging java and .net technology and critical trendsRakesh Jha
 
Ways to be a great project manager
Ways to be a great project managerWays to be a great project manager
Ways to be a great project managerRakesh Jha
 
What is mobile wallet
What is mobile walletWhat is mobile wallet
What is mobile walletRakesh Jha
 
Cordova vs xamarin vs titanium
Cordova vs xamarin vs titaniumCordova vs xamarin vs titanium
Cordova vs xamarin vs titaniumRakesh Jha
 
Mobile applications testing (challenges, tools & techniques)
Mobile applications testing (challenges, tools & techniques)Mobile applications testing (challenges, tools & techniques)
Mobile applications testing (challenges, tools & techniques)Rakesh Jha
 
Mobile testing practices
Mobile testing practicesMobile testing practices
Mobile testing practicesRakesh Jha
 
Advanced programing in phonegap
Advanced programing in phonegapAdvanced programing in phonegap
Advanced programing in phonegapRakesh Jha
 
Introduction phonegap
Introduction phonegapIntroduction phonegap
Introduction phonegapRakesh Jha
 
Advanced JQuery Mobile tutorial with Phonegap
Advanced JQuery Mobile tutorial with Phonegap Advanced JQuery Mobile tutorial with Phonegap
Advanced JQuery Mobile tutorial with Phonegap Rakesh Jha
 
Basics of css3
Basics of css3 Basics of css3
Basics of css3 Rakesh Jha
 
Introduction to jquery mobile with Phonegap
Introduction to jquery mobile with PhonegapIntroduction to jquery mobile with Phonegap
Introduction to jquery mobile with PhonegapRakesh Jha
 
Basics of HTML5 for Phonegap
Basics of HTML5 for PhonegapBasics of HTML5 for Phonegap
Basics of HTML5 for PhonegapRakesh Jha
 
Introduction of phonegap installation and configuration of Phonegap with An...
Introduction of phonegap   installation and configuration of Phonegap with An...Introduction of phonegap   installation and configuration of Phonegap with An...
Introduction of phonegap installation and configuration of Phonegap with An...Rakesh Jha
 
Android ndk - Introduction
Android ndk  - IntroductionAndroid ndk  - Introduction
Android ndk - IntroductionRakesh Jha
 
Native development kit (ndk) introduction
Native development kit (ndk)  introductionNative development kit (ndk)  introduction
Native development kit (ndk) introductionRakesh Jha
 
User experience and interactions design
User experience and interactions design User experience and interactions design
User experience and interactions design Rakesh Jha
 
Android coding standard
Android coding standard Android coding standard
Android coding standard Rakesh Jha
 
Optimisation and performance in Android
Optimisation and performance in AndroidOptimisation and performance in Android
Optimisation and performance in AndroidRakesh Jha
 
Multithreading and concurrency in android
Multithreading and concurrency in androidMultithreading and concurrency in android
Multithreading and concurrency in androidRakesh Jha
 
Android Design Architecture
Android Design ArchitectureAndroid Design Architecture
Android Design ArchitectureRakesh Jha
 

Mehr von Rakesh Jha (20)

Whitep paper on Emerging java and .net technology and critical trends
Whitep paper on Emerging java and .net technology and critical trendsWhitep paper on Emerging java and .net technology and critical trends
Whitep paper on Emerging java and .net technology and critical trends
 
Ways to be a great project manager
Ways to be a great project managerWays to be a great project manager
Ways to be a great project manager
 
What is mobile wallet
What is mobile walletWhat is mobile wallet
What is mobile wallet
 
Cordova vs xamarin vs titanium
Cordova vs xamarin vs titaniumCordova vs xamarin vs titanium
Cordova vs xamarin vs titanium
 
Mobile applications testing (challenges, tools & techniques)
Mobile applications testing (challenges, tools & techniques)Mobile applications testing (challenges, tools & techniques)
Mobile applications testing (challenges, tools & techniques)
 
Mobile testing practices
Mobile testing practicesMobile testing practices
Mobile testing practices
 
Advanced programing in phonegap
Advanced programing in phonegapAdvanced programing in phonegap
Advanced programing in phonegap
 
Introduction phonegap
Introduction phonegapIntroduction phonegap
Introduction phonegap
 
Advanced JQuery Mobile tutorial with Phonegap
Advanced JQuery Mobile tutorial with Phonegap Advanced JQuery Mobile tutorial with Phonegap
Advanced JQuery Mobile tutorial with Phonegap
 
Basics of css3
Basics of css3 Basics of css3
Basics of css3
 
Introduction to jquery mobile with Phonegap
Introduction to jquery mobile with PhonegapIntroduction to jquery mobile with Phonegap
Introduction to jquery mobile with Phonegap
 
Basics of HTML5 for Phonegap
Basics of HTML5 for PhonegapBasics of HTML5 for Phonegap
Basics of HTML5 for Phonegap
 
Introduction of phonegap installation and configuration of Phonegap with An...
Introduction of phonegap   installation and configuration of Phonegap with An...Introduction of phonegap   installation and configuration of Phonegap with An...
Introduction of phonegap installation and configuration of Phonegap with An...
 
Android ndk - Introduction
Android ndk  - IntroductionAndroid ndk  - Introduction
Android ndk - Introduction
 
Native development kit (ndk) introduction
Native development kit (ndk)  introductionNative development kit (ndk)  introduction
Native development kit (ndk) introduction
 
User experience and interactions design
User experience and interactions design User experience and interactions design
User experience and interactions design
 
Android coding standard
Android coding standard Android coding standard
Android coding standard
 
Optimisation and performance in Android
Optimisation and performance in AndroidOptimisation and performance in Android
Optimisation and performance in Android
 
Multithreading and concurrency in android
Multithreading and concurrency in androidMultithreading and concurrency in android
Multithreading and concurrency in android
 
Android Design Architecture
Android Design ArchitectureAndroid Design Architecture
Android Design Architecture
 

Kürzlich hochgeladen

Mobile Application Development-Android and It’s Tools
Mobile Application Development-Android and It’s ToolsMobile Application Development-Android and It’s Tools
Mobile Application Development-Android and It’s ToolsChandrakantDivate1
 
Mobile App Penetration Testing Bsides312
Mobile App Penetration Testing Bsides312Mobile App Penetration Testing Bsides312
Mobile App Penetration Testing Bsides312wphillips114
 
Mobile Application Development-Components and Layouts
Mobile Application Development-Components and LayoutsMobile Application Development-Components and Layouts
Mobile Application Development-Components and LayoutsChandrakantDivate1
 
Satara Call girl escort *74796//13122* Call me punam call girls 24*7hour avai...
Satara Call girl escort *74796//13122* Call me punam call girls 24*7hour avai...Satara Call girl escort *74796//13122* Call me punam call girls 24*7hour avai...
Satara Call girl escort *74796//13122* Call me punam call girls 24*7hour avai...nishasame66
 
Android Application Components with Implementation & Examples
Android Application Components with Implementation & ExamplesAndroid Application Components with Implementation & Examples
Android Application Components with Implementation & ExamplesChandrakantDivate1
 

Kürzlich hochgeladen (6)

Obat Penggugur Kandungan Di Apotik Kimia Farma (087776558899)
Obat Penggugur Kandungan Di Apotik Kimia Farma (087776558899)Obat Penggugur Kandungan Di Apotik Kimia Farma (087776558899)
Obat Penggugur Kandungan Di Apotik Kimia Farma (087776558899)
 
Mobile Application Development-Android and It’s Tools
Mobile Application Development-Android and It’s ToolsMobile Application Development-Android and It’s Tools
Mobile Application Development-Android and It’s Tools
 
Mobile App Penetration Testing Bsides312
Mobile App Penetration Testing Bsides312Mobile App Penetration Testing Bsides312
Mobile App Penetration Testing Bsides312
 
Mobile Application Development-Components and Layouts
Mobile Application Development-Components and LayoutsMobile Application Development-Components and Layouts
Mobile Application Development-Components and Layouts
 
Satara Call girl escort *74796//13122* Call me punam call girls 24*7hour avai...
Satara Call girl escort *74796//13122* Call me punam call girls 24*7hour avai...Satara Call girl escort *74796//13122* Call me punam call girls 24*7hour avai...
Satara Call girl escort *74796//13122* Call me punam call girls 24*7hour avai...
 
Android Application Components with Implementation & Examples
Android Application Components with Implementation & ExamplesAndroid Application Components with Implementation & Examples
Android Application Components with Implementation & Examples
 

Advance ui development and design

  • 1. Advance UI : Development and Design Rakesh Kumar Jha M. Tech, MBA Delivery Manager
  • 2. Android Windowing System What is Android windowing system Overview Architecture Components Development Code Q & A
  • 3. What is Android windowing system  In computing, a windowing system (or window system) is a type of graphical user interface (GUI) which implements the WIMP (windows, icons, menus, pointer) paradigm for a user interface.
  • 4. What is Android windowing system Most popular windowing systems are X11 and Wayland Most popular widget toolkits are GTK+/Clutter and Qt Most popular desktop environments are GNOME and the KDE Software Compilation
  • 5. X Window The X Window System (sometimes referred to as "X" or as "XWindows") is an open, cross- platform, client/server system for managing a windowed graphical user interface in a distributed network.  is a windowing system for bitmap displays, common on UNIX-like computer operating systems.
  • 9. Building Blocks There are more, but we focus on SurfaceManager WindowManager ActivityManager
  • 11. SurfaceManager  It is used for compositing window manager with off-screen buffering. Off-screen buffering means you cant directly draw into the screen, but your drawings go to the off-screen buffer. There it is combined with other drawings and form the final screen the user will see. This off screen buffer is the reason behind the transparency of windows.
  • 12. WindowManager frameworks/base/services/java/com/android/ server/WindowManagerService.java (Ask SurfaceManager to) create/layout surfaces on behalf of the clients Dispatch input events to clients Transition animation WindowManagerPolicy
  • 13. WindowManager The interface that apps use to talk to the window manager. Use Context.getSystemService(Context.WIND OW_SERVICE) to get one of these.
  • 14. WindowManager Each window manager instance is bound to a particular Display. To obtain a WindowManager for a different display, use createDisplayContext(Display) to obtain a Context for that display, then use Context.getSystemService(Context.WINDO W_SERVICE) to get the WindowManager.
  • 15. ActivityManager frameworks/base/services/java/com/android/ server/am/ Manage lifecycles of activities Manage stacking of activities Dispatch intents Spawn processes
  • 16. ActivityManager Interact with the overall activities running in the system. Information you can retrieve about the available memory Information you can retrieve about any processes that are in an error condition. Information you can retrieve about a running process. ActivityManager.MemoryInfo, ActivityManager.RunningAppProcessInfo
  • 17. An activity has one or more windows (e.g. dialogs) A window has one or more surfaces (e.g. surface views) However, in window manager, a window is called a session A surface is called a window
  • 18. How Android Draws Views? • When an Activity receives focus, it will be requested to draw its layout. • The Android framework will handle the procedure for drawing, but the Activity must provide the root node of its layout hierarchy.
  • 19. How Android Draws Views? • When an Activity receives focus, it will be requested to draw its layout. • The Android framework will handle the procedure for drawing, but the Activity must provide the root node of its layout hierarchy. • Drawing the layout is a two pass process: a measure pass and a layout pass.
  • 21. Handling Gestures Some examples of common multi-touch gestures and actions you might use include: Pinch to zoom in, spread to zoom out. Basic dragging in order to move, adjust, scroll, and position. Flick to jump to the next screen or scroll extra fast. Tap and hold to open an item or context menu. Multi-finger drag often scrolls faster!
  • 22. Handling Gestures Handling multi touch gesture Detecting common gesture Managing touch event Animating a scroll gesture Tracking movement Dragging & scalling
  • 23. Handling Gestures Android provides special types of touch screen events such as pinch , double tap, scrolls , long presses and flinch. These are all known as gestures.
  • 24. Handling Gestures Android provides GestureDetector class to receive motion events and tell us that these events correspond to gestures or not.
  • 25. Handling Gestures To use it , you need to create an object of GestureDetector and then extend another class with GestureDetector.SimpleOnGestureListener to act as a listener and override some methods.
  • 26. Handling Gestures GestureDetector myG; myG = new GestureDetector(this,new Gesture()); class Gesture extends GestureDetector.SimpleOnGestureListener{ public boolean onSingleTapUp(MotionEvent ev) { } public void onLongPress(MotionEvent ev) { } public boolean onScroll(MotionEvent e1, MotionEvent e2, float distanceX, float distanceY) { } public boolean onFling(MotionEvent e1, MotionEvent e2, float velocityX, float velocityY) { } } }
  • 27. Handling Pinch Gesture Android provides ScaleGestureDetector class to handle gestures like pinch e.t.c. In order to use it , you need to instantiate an object of this class. Its syntax is as follow: - ScaleGestureDetector SGD; SGD = new ScaleGestureDetector(this,new ScaleListener());
  • 28. Handling Pinch Gesture  We have to define the event listener and override a function OnTouchEvent to make it working. public boolean onTouchEvent(MotionEvent ev) { SGD.onTouchEvent(ev); return true; } private class ScaleListener extends ScaleGestureDetector.SimpleOnScaleGestureListener { @Override public boolean onScale(ScaleGestureDetector detector) { float scale = detector.getScaleFactor(); return true; } }
  • 29. Handling Pinch Gesture Apart from the pinch gestures , there are other methods avaialible that notify more about touch events. They are listed below: 1 getEventTime() This method get the event time of the current event being processed.. 2 getFocusX() This method get the X coordinate of the current gesture's focal point. 3 getFocusY() This method get the Y coordinate of the current gesture's focal point. 4 getTimeDelta() This method return the time difference in milliseconds between the previous accepted scaling event and the current scaling event. 5 isInProgress() This method returns true if a scale gesture is in progress.. 6 onTouchEvent(MotionEvent event) This method accepts MotionEvents and dispatches events when appropriate.
  • 30. Handling Pinch Gesture Use of ScaleGestureDetector class. It creates a basic application that allows you to zoom in and out through pinch.
  • 32. Animation in Android • Animation in android is possible from many ways. • making animation called tweened animation.
  • 33. Animation in Android • Animation in android is possible from many ways. • making animation called tweened animation.
  • 34. Tween Animation • Tween Animation takes some parameters such as start value , end value, size , time duration , rotation angle e.t.c and perform the required animation on that object.
  • 35. Tween Animation • In order to perform animation in android , call a static function loadAnimation() of the class AnimationUtils. Animation animation = AnimationUtils.loadAnimation(getApplicationContext(), R.anim.myanimation); second parameter, it is the name of the our animation xml file.
  • 36. Sr.No Method & Description 1 start() This method starts the animation. 2 setDuration(long duration) This method sets the duration of an animation. 3 getDuration() This method gets the duration which is set by above method 4 end() This method ends the animation. 5 cancel() This method cancels the animation. Tween Animation
  • 37. Tween Animation ImageView image1 = (ImageView)findViewById(R.id.imageView1); image.startAnimation(animation);
  • 38. Zoom in animation • To perform a zoom in animation , create an XML file under anim folder under res directory, and put zoom xml code. <set xmlns:android="http://schemas.android.com/apk/res/android"> <scale xmlns:android="http://schemas.android.com/apk/res/android" android:fromXScale="0.5" android:toXScale="3.0" android:fromYScale="0.5" android:toYScale="3.0" android:duration="5000" android:pivotX="50%" android:pivotY="50%" > </scale> </set>
  • 39. Zoom in animation • The parameter fromXScale and fromYScale define s the start point and the parameters toXScale andtoYScale defines the end point. • The duration defines the time of animation and the pivotX, pivotYdefines the center from where the animation would start.
  • 40. Custom UI Views Architecture
  • 41. • Android offers a sophisticated and powerful componentized model for building your UI, based on the fundamental layout classes: View and ViewGroup. • A partial list of available widgets includes Button, TextView, EditText, ListView, CheckBox, RadioButton, Gallery, Spinner, and the more special- purpose AutoCompleteTextView, ImageSwitcher, and TextSwitcher. • Among the layouts available are LinearLayout, FrameLayout, RelativeLayout, and others
  • 42. • If none of the prebuilt widgets or layouts meets your needs, you can create your own View subclass.
  • 43. View Hierarchy Design • Sometimes your application's layout can slow down your application. To help debug issues in your layout, the Android SDK provides the Hierarchy Viewer and lint tools.
  • 44. View Hierarchy Design • The Hierarchy Viewer application allows you to debug and optimize your user interface • It provides a visual representation of the layout's View hierarchy
  • 45. View Hierarchy Design • Android lint is a static code scanning tool that helps you optimize the layouts and layout hierarchies of your applications, as well as detect other common coding problems.
  • 46. Using Hierarchy Viewer • Connect your device or launch an emulator. To preserve security, Hierarchy Viewer can only connect to devices running a developer version of the Android system. • If you have not done so already, install the application you want to work with. • Run the application, and ensure that its UI is visible. • From a terminal, launch hierarchyviewer from the <sdk>/tools/ directory. • Window will launched with device list • Select apps name(packagename) and perform operaion.
  • 47.
  • 48. Using Hierarchy Viewer • The View Hierarchy window displays the View objects that form the UI of the Activity that is running on your device or emulator. • You should see four panes:- – Tree View: – Tree Overview, – Layout View, – Properties View
  • 49. Using Hierarchy Viewer • When the UI of the current Activity changes, the View Hierarchy window is not automatically updated. • To update it, click Load View Hierarchy at the top of the window.
  • 50.
  • 51. Working with an individual View in Tree View • Each node in Tree View represents a single View. Some information is always visible. • Starting at the top of the node, you see the following:
  • 52. Working with an individual View in Tree View 1. View class: The View object's class. 2. View object address: A pointer to View object. 3. View object ID: The value of the android:id attribute. 4. Performance indicators: 1. Green: Fastest, 50% faster than view object 2. Yellow : slower 50% of all the View objects 3. Red : slowest one in the tree
  • 53. Working with an individual View in Tree View 5. View index: The zero-based index of the View in its parent View. If it is the only child, this is 0.
  • 54. Using lint to Optimize Your UI • The Android lint tool lets you analyze the XML files that define your application's UI to find inefficiencies in the view hierarchy. • Note: The Android layoutopt tool has been replaced by the lint tool beginning in ADT and SDK Tools revision 16. The lint tool reports UI layout performance issues in a similar way as layoutopt, and detects additional problems.
  • 55. Using lint to Optimize Your UI • Improving Your Code with lint • The Android SDK provides a code scanning tool called lint that can help you to easily identify and correct problems with the structural quality of your code, without having to execute the app or write any test cases.
  • 56. Using lint to Optimize Your UI • The lint tool checks your Android project source files for potential bugs and optimization improvements for correctness, security, performance, usability, accessibility, and internationalization. • You can run lint from the command-line or from the Eclipse environment.
  • 57. Running lint from Eclipse If the ADT Plugin is installed in your Eclipse environment, the lint tool runs automatically when you perform one of these actions: Export an APK Edit and save an XML source file in your Android project (such as a manifest or layout file) Use the layout editor in Eclipse to make changes
  • 58. Running lint from the Command-Line • To run lint against a list of files in a project directory: int [flags] <project directory> lint --check MissingPrefix myproject
  • 59. Configuring lint You can configure lint checking at different levels: Globally, for all projects Per project Per file Per Java class or method (by using the @SuppressLint annotation), or per XML element (by using the tools:ignoreattribute.
  • 60. Configuring lint in Eclipse You can configure global, project-specific, and file-specific settings for lint from the Eclipse user interface.
  • 61. Global preferences • Open Window > Preferences > Android > Lint Error Checking. • Specify your preferences and click OK.
  • 62. Project and file-specific preferences • Run the lint tool on your project by right- clicking on your project folder in the Package Explorer and selecting Android Tools > Run Lint: Check for Common Errors. • From the Lint Warnings view, use the toolbar options to configure lint preferences for individual projects and files in Eclipse.
  • 63. Project and file-specific preferences The options you can select include: • Suppress this error with an annotation/attribute - If the issue appears in a Java class, the lint tool adds a@SuppressLint annotation to the method where the issue was detected. If the issue appears in an .xml file, lintinserts a tools:ignore attribute to disable checking for the lint issue in this file. • Ignore in this file - Disables checking for this lint issue in this file. • Ignore in this project - Disables checking for this lint issue in this project. • Always ignore - Disables checking for this lint issue globally for all projects.
  • 64. Configuring the lint file You can specify your lint checking preferences in the lint.xml file.  If you are creating this file manually, place it in the root directory of your Android project. If you are configuring lint preferences in Eclipse, the lint.xml file is automatically created and added to your Android project for you.
  • 65. Sample lint.xml file <?xml version="1.0" encoding="UTF-8"?> <lint> <!-- Disable the given check in this project --> <issue id="IconMissingDensityFolder" severity="ignore" /> <!-- Ignore the ObsoleteLayoutParam issue in the specified files --> <issue id="ObsoleteLayoutParam"> <ignore path="res/layout/activation.xml" /> <ignore path="res/layout-xlarge/activation.xml" /> </issue> <!-- Ignore the UselessLeaf issue in the specified file --> <issue id="UselessLeaf"> <ignore path="res/layout/main.xml" /> </issue> <!-- Change the severity of hardcoded strings to "error" --> <issue id="HardcodedText" severity="error" /> </lint>
  • 66. Event Propagation and Event Handling in Views For each application, a ViewRootImpl object is created to handle communications with the remote system WindowManagerService object. The communication is through a Linux pipe which is encapsulated in an InputChannel object (mInputChannel field in class ViewRootImpl). TheViewRootImpl object also registers an instance of InputEventReceiver when the first View object is registered with it.
  • 67. Event Propagation and Event Handling in Views public void setView(View view, ...) { ... mInputEventReceiver = new WindowInputEventReceiver(mInputChannel, Looper.myLooper()); ... } The constructor of class WindowInputEventReceiver (class WindowManagerService extends from classInputEventReceiver) calls a native methond nativeInit(...):
  • 68. Event Propagation and Event Handling in Views 58 public InputEventReceiver(InputChannel inputChannel, Looper looper) { ... 66 mInputChannel = inputChannel; 67 mMessageQueue = looper.getQueue(); 68 mReceiverPtr = nativeInit(this, inputChannel, mMessageQueue); ... 71 }
  • 69. Event Propagation and Event Handling in Views Three parameters are passed to the native function nativeInit: 1) The receiver object itself; 2) TheInputChannel object passed from the ViewRootImpl object. 3) The main message queue (an object of class MessageQueue) of the application.
  • 70. Event Propagation and Event Handling in Views 227 static jint nativeInit(JNIEnv* env, jclass clazz, jobject receiverObj, 228 jobject inputChannelObj, jobject messageQueueObj) { 229 sp<InputChannel> inputChannel = android_view_InputChannel_getInputChannel(env, 230 inputChannelObj); ... 236 sp<MessageQueue> messageQueue = android_os_MessageQueue_getMessageQueue(env, messageQueueObj); ... 242 sp<NativeInputEventReceiver> receiver = new NativeInputEventReceiver(env, 243 receiverObj, inputChannel, messageQueue); 244 status_t status = receiver->initialize(); ... 254 }
  • 71. Event Propagation and Event Handling in Views Included in the event listener interfaces are the following callback methods:- onClick() onLongClick() onFocusChange() onKey() onTouch() onCreateContextMenu()
  • 72. Event Propagation and Event Handling in Views Included in the event listener interfaces are the following callback methods:- onClick() onLongClick() onFocusChange() onKey() onTouch() onCreateContextMenu()
  • 73.
  • 74.
  • 76. • An android application can run on many devices in many different regions. • In order to make your application more interactive, your application should handle text,numbers,files e.t.c in ways appropriate to the locales where your application will be used.
  • 77. Localizing Strings • In order to localize the strings used in your application , make a new folder under res with name ofvalues-local where local would be the replaced with the region. • For example, in the case of italy, the values- it folder would be made under res. It is shown in the image below:
  • 79. Localizing Strings • Once that folder is made, copy the strings.xmlfrom default folder to the folder you have created. And change its contents. For example, i have changed the value of hello_world string.
  • 80. Localizing Strings • ITALY, RES/VALUES-IT/STRINGS.XML <;?xml version="1.0" encoding="utf-8"?> <resources> <string name="hello_world">Ciao mondo!</string> </resources>
  • 81. Localizing Strings • Chinese, RES/VALUES-zh/STRINGS.XML <;?xml version="1.0" encoding="utf-8"?> <resources> <string name="hello_world">Hola Mundo!</string> </resources>
  • 82. Localizing Strings • FRENCH, RES/VALUES-FR/STRINGS.XML <;?xml version="1.0" encoding="utf-8"?> <resources> <string name="hello_world">Bonjour le monde !</string> </resources>