starting development

52
Starting Development Nasrullah

Upload: mckenzie-pearson

Post on 01-Jan-2016

26 views

Category:

Documents


2 download

DESCRIPTION

Starting Development. Nasrullah. What you need to begin. Android application run with in a Dalvik virtual machine, you can write them on any platform that supports the developer tools. Microsoft Windows Mac OS X10.4.8 or later Linux. Installation. - PowerPoint PPT Presentation

TRANSCRIPT

Page 1: Starting Development

Starting Development

Nasrullah

Page 2: Starting Development

What you need to begin

• Android application run with in a Dalvik virtual machine, you can write them on any platform that supports the developer tools.

• Microsoft Windows• Mac OS X10.4.8 or later• Linux

Page 3: Starting Development

Installation

Page 4: Starting Development

• To get started you need to download and install the following

• The Android SDK• Java Development kit (5 or 6)

• You can download jdk 6.0 from herehttp://www.oracle.com/technetwork/java/javase/downloads/index.html

Page 5: Starting Development
Page 6: Starting Development

Download and installing SDK • Android development home pagehttp://developer.android.com/sdk/index.html

You need atleast on SDK platform ,you can do this ,you can do this by on Windows by running SDK Setup.exe.

Page 7: Starting Development
Page 8: Starting Development

• Step 3:-You have to download eclipse with ADT plug-inTo download the eclipse http://www.eclipse.org/downloads/

Page 9: Starting Development

Using the eclipse plugin

The ADT plugin for elipse simplifies your

Android development by integrating the

development tools directly into IDE,

Page 10: Starting Development

Installing ADT Plug-in

Page 11: Starting Development
Page 12: Starting Development

If you are behind a firewall (such as a IBA firewall), make sure that you have properly configured your proxy settings in Eclipse. In Eclipse, you can configure proxy information from the main Eclipse menu in Window >Preferences > General > Network Connections.

Page 13: Starting Development

Window > Preferences> Android

modify your ADT preferences in Eclipse to point to the Android SDK directory:(very important)

Page 14: Starting Development

Creating your first Android Application

Page 15: Starting Development
Page 16: Starting Development
Page 17: Starting Development
Page 18: Starting Development
Page 19: Starting Development
Page 20: Starting Development
Page 21: Starting Development
Page 22: Starting Development
Page 23: Starting Development
Page 24: Starting Development

The template “Iba_World, created by the wizard overrides the onCreate method to call the setContentView,which lays our her interface by inflating a layout resource.

Page 25: Starting Development

The resource of an android project are stored in res folder of your project hierarchy,which includes drawables,layouts,values.The ADT Plugin interprets these resources to provide design time access to them through R variable

Page 26: Starting Development
Page 27: Starting Development

Defining your UI in XML and inflating it is the preferred way of implementing your user interfaces, as it neatly decouples your application logic from your UI design.To get access to your UI elements in code ,you add identifier attributes to them in the XML definition.You can then use the findViewById method to return a reference to each nameditem.

Page 28: Starting Development

TextView text = (TextView) findViewById(R.id.myTextView);

How to access it into the code

Page 29: Starting Development

Android Application Component

Page 30: Starting Development

Important Android Compnents(Activity)1

• Activity represents the presentation layer of an Android application. A simplified (and slightly incorrect) description is that an Activity is a a screen which the user sees.. An Android application can have several activities and it can be switched between them during runtime of the application.

Page 31: Starting Development

Important android components

• Views are user interface widgets, e.g. buttons or text fields. The base class for all Views is android.view.View. The layout of the Views is managed by subclasses of type android.view.ViewGroups. Views often have attributes which can be used to change their appearance and behavior.

Page 32: Starting Development

Important android compnents(services)

• Services perform background tasks without providing an UI. They can notify the user via the notification framework in Android.

Page 33: Starting Development

Important android compnents(ContentProvider)

• ContentProvider provides an structured interface to data. Via a ContentProvider your application can share data with other applications. Android contains an SQLite database which is frequently used in conjunction with a ContentProvider to persists the data of the ContentProvider.

Page 34: Starting Development

Important android compnents(Intents• Intents are asynchronous messages which allow the

application to request functionality from other components of the Android systen, e.g. from Services or Activities. An application can call a component directly (explicit intent) or ask the Android system to evaluate registered components for a certain Intents (implicit intents). For example the application could implement sharing of data via an Intent and all components which allow sharing of data would be available for the user to select. Applications register themselves to an intent via an IntentFilter. Intents allow to combine loosely coupled components to perform certain tasks.

Page 35: Starting Development

Important android compnents(BroadcastReceiver)

• BroadcastReceiver can be registered to receives system messages and Intents. BroadcastReceiver will get notified by the Android system if the specified situation happens. For example a BroadcastReceiver could get called once the system completed its boot process or if a phone call is received.

Page 36: Starting Development

Important android compnents(widgets)• Widgets are interactive components which are

primary used on the Android homescreen. They typically display some kind of data and allow the user to perform actions via them. For example a Widget could display a short summary of new emails and if the user select a email it could start the email application with the selected email

Page 37: Starting Development

• You need Android SDK and JDK(java development kit) to build Android Applications.

• Android code is written with java syntax, before it can be run ,your project must first be translated into Dalvik byte code.

• SDK download includes all the libraries, full documentation and sample applications, Android emulator and Dalvik Debug Monitoring Service(DDMS) to help debug them.

Page 38: Starting Development

Types of Android Applications1. Foreground:- an application that is usefull

when it is in the foreground and is effectively suspended when it is not visible.Games and map mashups are common examples.

2. Background:- These applications run silently in the background with very little user input.They often listen for messages and actions caused by the hardware,system ,or other applications, rather than rely on the user interaction

Page 39: Starting Development

Continued3. Intermittent:- often you want to create the

application that react to user input but is still usefull when it is not active in the foreground,Chat and e-mail apps are typical examples.these applications are generally a union of visible activities and invisible background services.

Page 40: Starting Development

• Continued4. Widgets in some circumstances your

application my entirely consists of a widget component.using widgets,you can create interactice visual compnents that users can add to their home screens,widgets only applications are used to display dynamic information such as battery levels,weather froecast or the date and time

Page 41: Starting Development

Developing for mobile devicesCompared to desktops and notebook computers

mobile devices have relatively1. Low processing power2. Limited Ram3. Limited permanent storage capacity4. Small screen with low resolution5. High cost associated with data transfer6. Slow data trasfer rate with low latency7. Unreliable data connections8. Limited battery life

Page 42: Starting Development

• Be efficient :- mobile devices are valued by their small size and long battery life over potential improvement in processor speed

• This means that you always need to optimize your code so that it runs quickly and responsively .

• Code efficiency is a big topic in software engineering.

• Efficiency is important for resource-constrained environments like mobile devices.

Page 43: Starting Development

• Expect limited capacity :-Advances in Flash memory and solid-state disks have

led to a dramatic increase in mobile-device storage capacities.

Android applications must be installed on the internal memory.

You should carefully consider how you store your application data .To make life easier you can use the Android database and content providers to persist,reuse and share large quantities of data

Don’t leave files on the file system or records in database when they are no longer needed.

Page 44: Starting Development

• Design for small screens:- The small sizes and protability of mobiles are a challenge for creating good interfaces.Write your applications knowing that users will ofter only glance at the small screen.Make your application intuitive and easy to use by reducing the number of controls and putting the most important information front and center.Graphical controls are an excellent means of displaying of information in a way that is easy to understand.

Page 45: Starting Development

• Continued: rather than a screen full of text with lots of buttons and text-entry boxes ,use colors,shapes and graphics to convey the information.

• If you are planning to include touch-screen support,you ‘ll need to consider how touch input is going to affect your interface design,so make sure ,your views are big enough to support interaction using a finger on the screen.

Page 46: Starting Development

• Expect Low speeds ,High Latency:- when you are developing your internet based applications,it is best to assume that the internnet connection would be slow,intermittent,and expensive,with unlimited 3G plans and citywide wi-fi ,this is changing,but design for worst case ensures that you always deliver a high standard uer experience.

• This means making sure that your application can handle losing (or not finding) a data connction.

Page 47: Starting Development

• At What Cost:- some of the more powerful features on your mobile can come at price.Services like SMS,some location based services and data transfer can sometimes incur an additional tariff from your service provider.

• Costs associated with functionality in your application be minimized and the users be aware when an action they perform might result in their being charged

• Minimize the interaction costs by doing the followingTrasferring as little data as possibleCaching data and GPS results to eliminate redundant or repetitive

lookups.Stopping all data transfers and GPS updates when your activity is

not visible in the foreground and if they are being used to update the UI

Keeping the refresh/update rates for data transfer (and location lookups) as low as practicable

Page 48: Starting Development

• Continued:- • Scheduling big updates or transfer at “ off-

peak” times using alarams• Respecting the user’s preferenced for

backgound data transfer.• The best solution is to use a lower quality

option that comes at a lower cost.

Page 49: Starting Development

Android Emulator• The android emulator is a perfect tool for testing and

debugging your application,• Emulator is an implementation of Dalvik virtual

machine,making it a valid platform for running android application as any android phone.u

• ADT PLUG-IN integrates the emulator into the Eclipse• To execute the emulator ,you need to create the virtual

device.• Emulator doesn’t implement all the mobile hardware

features supported by the android,it does not implement the camera,vibration,LEDs,actual phone calls,the accelometer,USB connections,audio capture,or battery charge level

Page 50: Starting Development

Short cuts for emulator

• Alt+Enter maximizes the emulator. Nice for demos.

• Ctrl+F11 changes the orientation of the emulator.

• F8 turns network on / off.

Page 51: Starting Development

Dalvik Debug Monitor Service• The emulator let you see how your application

will look,behave and interact , but to really see what’s happening under the surface you need the Dalvik Debug Monitoring Service,

• The DDMS is a powerful debugging tool that lets you interrogate active processes,view the stack and heap,watch and pause active threads and explore the file system of any connected Android device

Page 52: Starting Development

Android Debugging Bridge• The communication with the emulator or your

Android device might have problems. This communication is handled by the Android Debug Bridge (adb).

• Eclipse allows to reset the adb in case this causes problems. Select therefore the DDMS perspective via Window → Open Perspective → Other → DDMS