520 likes | 625 Views
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.
E N D
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
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 here http://www.oracle.com/technetwork/java/javase/downloads/index.html
Download and installing SDK • Android development home page http://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.
Step 3:- You have to download eclipse with ADT plug-in To download the eclipse http://www.eclipse.org/downloads/
Using the eclipse plugin The ADT plugin for elipse simplifies your Android development by integrating the development tools directly into IDE,
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.
Window > Preferences> Android modify your ADT preferences in Eclipse to point to the Android SDK directory:(very important)
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.
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
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.
How to access it into the code TextView text = (TextView) findViewById(R.id.myTextView);
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.
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.
Important android compnents(services) • Services perform background tasks without providing an UI. They can notify the user via the notification framework in Android.
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.
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.
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.
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
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.
Types of Android Applications • 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. • 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
Continued • 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.
Continued • Widgetsin some circumstances your application my entirely consists of a widget component.usingwidgets,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,weatherfroecast or the date and time
Developing for mobile devices Compared to desktops and notebook computers mobile devices have relatively • Low processing power • Limited Ram • Limited permanent storage capacity • Small screen with low resolution • High cost associated with data transfer • Slow data trasfer rate with low latency • Unreliable data connections • Limited battery life
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.
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.
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.
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.
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,andexpensive,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.
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 following Trasferring as little data as possible Caching 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
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.
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,theaccelometer,USBconnections,audiocapture,or battery charge level
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.