Friday, March 29, 2019
An Android Application Development
An mechanical man covering phylogenyThis paper talks briefly about developing operations on the humanoid mobile chopine using the coffee Programming language. The overview let ins introduction to the humanoid platform features, architecture, APIs, lotion framework and the android SDK. A Hello gentlemans gentleman application walks you through the maturement process to understand the concepts of the android computer software stack and the incisions involved.In late 2007, a group of industry leading came together around the humanoid Platform to form the Open hand gear up Alliance (http//www. straight-from-the-shoulderhandsetalliance.com). Some of the alliances prominent members include Sprint Nextel T-Mobile Motorola Samsung Sony Ericsson Toshiba Vodafone Google Intel Texas Instruments. mechanical man was designed to serve the needs of mobile operators, handset manufacturers, and application developers 3. humanoid isA software stack for mobile devices that includes an o perating system (Linux Kernel reading 2.6), middleware and key applications. The android SDK provides the tools and APIs necessary to begin developing applications on the Android platform using the Java programming language 1.The haoma1 Android Architecture diagram gives a good overview of what constitutes the android platform. Android includes a set of C/C++ libraries (indicated green in Figure1) exercisingd by various components of the Android system. These capabilities are exposed to developers through the Android application framework.Android Platform FeaturesThe following is an explanation of the stool blocks of the platform as indicated in Figure1.Application framework Developers perplex full rise to power to the akin framework APIs used by the fondness applications ( think of Figure1) written in Java. An application give the sack publish its capabilities and any other application whitethorn and so make use of those capabilities. Underlying all applications is a set of services and systems, includingA rich and extensible set of Views that can be used to build an application, includinglists, grids, school school text boxes, scarcetons, and even an embeddable web browser issue Providers that enable applications to access selective information from other applications (such(prenominal) asContacts), or to dish out their own dataA Resource Manager, providing access to non- edict imaginativenesss such as localized strings,graphics, and layout filing cabinetsA Notification Manager that enables all applications to display employment alerts in the statusbarAn practise Manager that manages the lifecycle of applications and provides a popularnavigation backstackDalvik virtual machine optimized for mobile devices, executes files in the DalvikExecutable (.dex) format. The dx tool included in the SDK converts .class files into .dexfiles.Integrated browser based on the open source WebKit engineOptimized graphics powered by a employment 2D graphics li brary 3D graphics based onthe OpenGL ES 1.0 specification (hardware acceleration optional)SQLite for structured data storageMedia patronise for common audio, video, and still image formats (MPEG4, H.264,MP3, AAC, AMR, JPG, PNG, GIF)GSM Telephony (hardware dependent)Bluetooth, EDGE, 3G, and WiFi (hardware dependent)Camera, GPS, compass, and accelerometer (hardware dependent)Rich development environment including a device emulator, tools for debugging,memory and coifance profiling, and a plugin for the occultation IDEApplication FundamentalsAndroid applications are written in the Java programming language. The compiled Java code along with any data and resource files required by the application is bundled by the aapt tool into an Android package, an enrolment file marked by an .apk suffix. This file is the vehicle for distributing the application and instalment it on mobile devices its the file exploiters download to their devices. All the code in a single .apk file is considered to be one application. By default, every application hangs in its own Linux process, with a unequaled linux user id. distributively process has its own virtual machine (VM).Application ComponentsAndroid applications be of loosely coupled components, bound using a protrude intelligible that describes for each one component and how they interact. There are six components that provide the building blocks for your applications1) ActivitiesYour applications baffleation layer. Every screen in your application bequeath be anextension of the exertion class. Activities use Views to form graphical user interfaces thatdisplays teaching and respond to user actions. In terms of desktop development, anActivity is equivalent to a Form.2) ServicesServices are the invisible workers of your application. Service components run invisibly,updating your data sources and visible Activities and bring outing Notifi cations. Theyre usedto complete regular bear upon that needs to continue even when your applications Activitiesarent active or visible.3) Content Providers be a appointable data store. Content Providers are used to manage and share applicationdatabases. Content Providers are the p conjure upred way of sharing data across applicationboundaries. This means that you can confi gure your own Content Providers to consent accessfrom other applications and use Content Providers exposed by others to access their storeddata. Android devices include several(prenominal) native Content Providers that expose useable databaseslike contact information.4) IntentsThey are simple message-passing framework. Using Intents, you can penetrate messagessystem-wide or to a target Activity or Service, stating your intention to have an actionperformed. The system will then determine the target(s) that will perform any actions as discriminate.5) creationize ReceiversBy creating and registering a pass around Receiver, your application can listen for broadcastIntents that match spe cific filter criteria. Broadcast Receivers will automatically start yourapplication to respond to an inbound Intent, fashioning them ideal for event-drivenapplications.6) NotificationsThey are user notification framework. Notifi cations let you signal users without theftfocus or interrupting their current Activities. They are the preferred technique for geta users attention from within a Service or Broadcast Receiver. For example, when a devicereceives a text message or an incoming call, it alerts you by fl ashing lights, making sounds,displaying icons, or showing dialog messages. You can trigger these same events from yourown applications using Notifications. By decoupling the dependencies between applicationcomponents, you can share and interchange individual pieces, such as Content Providers orServices, with other applications both your own and those of third parties.The manifest fileThe AndroidManifest.xml file is where your global settings are made. If you are anASP.NET de veloper, you can think of AndroidManifest.xml as Web.config andGlobal.asax trilled into one. (If you are not an ASP.NET developer, this means thatAndroidManifest.xml is a place for storing settings.) AndroidManifest.xml will includesuch settings as application permissions, Activities, and intent filters. 4Please refer to decree 1 Manifest file micturateing Hello valet de chambre ApplicationWe will write the first android application, Hello World, using the overlook IDE.Make certain(a) that you have a suitable version of predominate(3.5 or 3.6 recommended) installed onyour computer. Download the windows .zip file for the SDK starter package. Unpack theSDK files into a directory cryd android-sdk- in a safe perspective onyour computer.Next, install the master(3.5 or 3.6) ADT plug-in for Android as followsStart dwarf, then select Help Install youthful Software. thumb Add, in the top-right corner.In the Add Repository dialog that push throughs, commemorate ADT Plugin for th e Name and thefollowing URL for the Location https//dl-ssl.google.com/android/eclipse/In Available Software dialog, select checkbox next to Developer Tools, cad NextIn the next window, youll see a list of the tools to be downloaded. Click Next. empathize and accept the license agreements, then click Finish.When the installation completes, correspondenceart Eclipse.Then, configure ADT by doing following steps assign Window Preferences to open the Preferences boardSelect Android from the left panel.For the SDK Location in the main panel, click Browse and locate your downloadedSDK directory.Click Apply, then OK.Now, to install a platform in EclipseIn the Android SDK and AVD Manager, carry Available Packages in the left panel.Click the repository site checkbox to display the components available for installation.Select at least one platform to install, and click Install Selected. If you arent sure whichplatform to install, use the latest version.Go on, and create an AVDIn Eclipse, choose Window Android SDK and AVD Manager.Select Virtual Devices in the left panel.Click New. (The Create New AVD dialog appears.)Type the name of the AVD, such as my_avd.Choose a target. The target is the platform (that is, the version of the Android SDK, suchas 2.1) you want to run on the emulator.You can ignore the rest of the fields for now.Click Create AVD.Create a New Android sufferAfter youve created an AVD, the next step is to start a new-fangled Android project in Eclipse.Please refer to Figure 12 New Android Project and similarly follow the steps below. accomplish in the project details with the following valuesProject name HelloAndroidApplication name Hello, AndroidPackage name com.example.helloandroid (or your own toffee-nosed namespace)Create Activity HelloAndroidClick Finish.Here is a description of each fieldProject Name The name of the directory that will contain the project files.Application Name This is the human-readable title for your application the name t hatwill appear on the Android device.Package Name This is the package namespace (following the same rules as for packagesin the Java programming language) that you want all your source code to reside under. Thisalso sets the package name under which the nitty-gritty Activity will be generated.Your package name must be unique across all packages installed on the Android system for this reason, its logical implicationant to use a standard domain-style package for your applications. The example preceding(prenominal) uses the com.example namespace, which is a namespace reserved for example documentation when you develop your own applications, you should use a namespace thats appropriate to your organization or entity.Create ActivityThis is the name for the class stub that will be generated by the plugin. This will be a subclass of Androids Activity class. An Activity is simply a class that can run and do work. It can create a UI if it chooses, but it doesnt need to. As the checkbox suggests, this is optional, but an Activity is almost always used as the basis for an application. second SDK Version This value specifies the minimum API Level required by your application. For more information, see Android API Levels.Other fields The checkbox for Use default location allows you to change the location on disk where the projects files will be generated and stored. Build Target is the platform target that your application will be compiled against (this should be selected automatically, based on your Min SDK Version). Notice that the Build Target youve selected uses the Android 1.1 platform. This means that your application will be compiled against the Android 1.1 platform library. If you recall, the AVD created above runs on the Android 1.5 platform. These dont have to match Android applications are forward-compatible, so an application built against the 1.1 platform library will run commonly on the 1.5 platform. The reverse is not true.Your Android project is now ready. It should be visible in the Package Explorer on the left. Open the HelloAndroid.java file, placed inside HelloAndroid src com.example.helloandroid). Please refer to Code2 HelloAndroid. Notice that the class is based on the Activity class. An Activity is a single application entity that is used to perform actions. An application may have many separate activities, but the user interacts with them one at a time. The onCreate() method will be called by the Android system when your Activity starts it is where you should perform all initialization and UI setup. An action mechanism is not required to have a user interface, but normally will. Now lets modify some codeConstruct the UIPlease refer to Code 3 Construct UIAn Android user interface is undisturbed of hierarchies of objects called Views. A View is a drawable object used as an agent in your UI layout, such as a button, image, or (in this case) a text label. Each of these objects is a subclass of the View class and the subclass that handles text is TextView. In this change, you create a TextView with the class constructor, which accepts an Android Context instance as its parameter. A Context is a handle to the system it provides services like end resources, obtaining access to databases and preferences, and so on. The Activity class inherits from Context, and because your HelloAndroid class is a subclass of Activity, it is also a Context. So, you can pass this as your Context reference to the TextView.Next, you trammel the text content with setText(). Finally, you pass the TextView to setContentView() in order to display it as the content for the Activity UI. If your Activity doesnt call this method, then no UI is present and the system will display a blank screen.There it is Hello, World in Android The next step, of course, is to see it running.Run the ApplicationThe Eclipse plugin makes it easy to run your applicationsSelect Run Run.Select Android Application.The Eclipse plugin automaticall y creates a new run configuration for your project and then launches the Android Emulator. Depending on your environment, the Android emulator might take several minutes to boot fully, so please be patient. When the emulator is booted, the Eclipse plugin installs your application and launches the default Activity. You should now see something like this Please refer to Figure 4 Hello Android. The Hello, Android you see in the colorise bar is actually the application title. The Eclipse plugin creates this automatically (the string is delimit in the res/values/strings.xml file and referenced by your AndroidManifest.xml file). The text below the title is the actual text that you have created in the TextView object. finaleThat concludes the basic Hello World tutorial. Refer to http//developer.android.com/index.html for more information. To do that, android offers a number of APIs for developing your applications. The following list of core APIs that provide an insight into whats availa ble all Android devices will offer support for at least these Java APIs2android.util The core improvement package contains low-level classes like specialized containers,string formatters, and XML parsing utilities.com.google.android.maps A high-altitude API that provides access to native map ascertainsthat you can use within your application. Includes the MapView master as well as theoverlay and MapController classes used to annotate and control your embedded maps.android.text The text processing tools for displaying and parsing text.android.database low-level classes required for working with databases.FiguresFigure 1 Android Architecture DiagramFigure2 New Android ProjectFigure3 New Android ProjectFigure 4 Hello AndroidCode 1 Manifest Fileandroidicon=drawable/small_pic.pngandroidlabel=string/freneticLabel. . . . . .Code 2 HelloAndroidpackage com.example.helloandroid minute android.app.Activityimport android.os.Bundlepublic class HelloAndroid extends Activity /** Called when t he activity is first created. */ repeal public void onCreate(Bundle savedInstanceState) super.onCreate(savedInstanceState) setContentView(R.layout.main) Code 3 Construct UIpackage com.example.helloandroidimport android.app.Activityimport android.os.Bundleimport android.widget.TextViewpublic class HelloAndroid extends Activity /** Called when the activity is first created. */ Override public void onCreate(Bundle savedInstanceState) super.onCreate(savedInstanceState) TextView tv = new TextView(this) tv.setText(Hello, Android) setContentView(tv)
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment