Monday, June 3, 2019

An Android Application Development

An mechanical man Application DevelopmentThis paper talks briefly about develop activitys programmes on the android mobile computer program using the Java Programming language. The overview includes introduction to the android platform features, architecture, genus Apis, application framework and the android SDK. A hullo World application walks you through the information process to understand the concepts of the android software stack and the tools involved.In late 2007, a group of industry leaders came together around the humanoid program to form the Open Handset Alliance (http//www. escapedhandset alliance.com). Some of the alliances prominent members include Sprint Nextel T-Mobile Motorola Samsung Sony Ericsson Toshiba Vodaf bingle Google Intel Texas Instruments. mechanical man was designed to serve the needs of mobile operators, handset manufacturers, and application developers 3.Android isA software stack for mobile devices that includes an operating system (Linux Ker nel version 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 Figure1 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) utilisationd 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 expression blocks of the platform as indicated in Figure1.Application framework Developers have full admission price to the same framework APIs employ by the core applications ( interest Figure1) written in Java. An application go off publish its capabilities and any other application may then make use of those capabilities. Underlying all applications is a set of services and systems, includingA rich an d extensible set of Views that can be used to build an application, includinglists, grids, text boxes, buttons, and level(p) an embeddable web browser guinea pig Providers that enable applications to access data from other applications (such(prenominal) asContacts), or to share their own dataA Resource Manager, providing access to non- ordinance resources such as localized strings,graphics, and layout chargesA Notification Manager that enables all applications to display custom alerts in the statusbarAn Activity Manager that manages the lifecycle of applications and provides a commonnavigation backstackDalvik virtual machine optimized for mobile devices, executes files in the DalvikExecutable (.dex) format. The dx tool included in the SDK converts . configuration files into .dexfiles.Integrated browser based on the open source WebKit engineOptimized graphics powered by a custom 2D graphics library 3D graphics based onthe OpenGL ES 1.0 specification (hardware acceleration optional )SQLite for structured data storageMedia support 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, com ecstasy, and accelerometer (hardware dependent)Rich development environment including a device emulator, tools for debugging,memory and performance profiling, and a plugin for the Eclipse 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 archive file marked by an .apk suffix. This file is the vehicle for distributing the application and installing it on mobile devices its the file users download to their devices. All the code in a single .apk file is considered to be one application. By default option, every application runs in its own Linux process, with a unique linux user id. Each process has its own virtual machine (VM).Application ComponentsAndroid applications consist of loosely coupled components, bound using a project manifest that describes each component and how they interact. There are six components that provide the building blocks for your applications1) ActivitiesYour applications presentation layer. Every screen in your application go forth be anextension of the Activity class. Activities use Views to form graphical user interfaces thatdisplays information and reply 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 triggering Notifi cations. Theyre usedto perform regular processing that needs to continue even when your applications Activitiesarent active or visible.3) capacity ProvidersAre a shareable data store. Content Providers ar e used to manage and share applicationdatabases. Content Providers are the p attendred way of sharing data across applicationboundaries. This means that you can confi gure your own Content Providers to permit accessfrom other applications and use Content Providers exposed by others to access their storeddata. Android devices include several native Content Providers that expose useful databaseslike contact information.4) IntentsThey are simple message-passing framework. Using Intents, you can broadcast messagessystem-wide or to a target Activity or Service, stating your invention to have an actionperformed. The system will then determine the target(s) that will perform any actions asappropriate.5) Broadcast ReceiversBy creating and registering a Broadcast Receiver, your application can listen for broadcastIntents that match specific filter criteria. Broadcast Receivers will automatically start yourapplication to respond to an incoming Intent, making them lofty for event-drivenappli cations.6) NotificationsThey are user notification framework. Notifi cations let you signal users without stealingfocus or interrupting their current Activities. They are the p put forwardred technique for gettinga users assist 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 developer, you can gestate of AndroidManifest.xml as Web.config andGlobal.asax rolled into one. (If you are not an ASP.NET developer, this means thatAndr oidManifest.xml is a place for storing settings.) AndroidManifest.xml will includesuch settings as application permissions, Activities, and intent filters. 4 delight refer to Code 1 Manifest fileBuilding Hello World ApplicationWe will write the first android application, Hello World, using the predominate IDE.Make legitimate that you have a suitable version of Eclipse(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 have-to doe withd android-sdk- in a safe location onyour computer.Next, install the Eclipse(3.5 or 3.6) ADT plug-in for Android as followsStart Eclipse, then recognise Help Install New Software.Click Add, in the top-right corner.In the Add Repository dialog that appears, enter ADT Plugin for the Name and thefollowing URL for the Location https//dl-ssl.google.com/android/eclipse/In available Software dialog, select checkbox following to Developer Tools, detent NextIn the next window, youll see a list of the tools to be downloaded. Click Next.Read and accept the license agreements, then click Finish.When the installation completes, restart Eclipse.Then, configure ADT by doing following steps mete out Window Preferences to open the Preferences panelSelect 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, choose 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 establish 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 compliments to run on the emulator.You can ignore the rest of the fields for now.Click get to AVD.Create a New Android ProjectAfter youve created an AVD, the next step is to start a new Android project in Eclipse.Please refer to Figure 12 New Android Project and too follow the steps below.Fill in the project details with the following valuesProject name HelloAndroidApplication name Hello, AndroidPackage name com.example.helloandroid (or your own private namespace)Create Activity HelloAndroidClick Finish.Here is a description of each fieldProject Name The name of the directory that will pick out the project files.Application Name This is the human-readable title for your application the name thatwill 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 resi de under. Thisalso sets the package name under which the stub Activity will be generated.Your package name must be unique across all packages installed on the Android system for this reason, its important to use a measurement domain-style package for your applications. The example above 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.Min SDK Version This value specifies the minimum API Level required by your application. For more information, see Android API Levels.O ther 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 normally on the 1.5 platform. The a obviate 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, located inside HelloAndroid src com.example.helloandroid). Please refer to Code2 HelloAndroid. Notice that the class is based on the Act ivity class. An Activity is a single application entity that is used to perform actions. An application may have umteen 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 activity is not required to have a user interface, but usually will. Now lets modify some codeConstruct the UIPlease refer to Code 3 Construct UIAn Android user interface is composed 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 resolving 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 define 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 automatically creates a new run configuration for your project and then launches the Android Emulator. Depending on your environment, the Android emulator might persuade 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 grey bar is actually the application title. The Eclipse plugin creates this automatically (the string is defined 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.ConclusionThat 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 brainwave into whats available all Android devices will offer support for at least these Java APIs2android.util The core utility package contains low-level classes like specialized containers,string formatters, and XML parsing utilities.com.google.android.maps A hig h-level API that provides access to native map controlsthat you can use within your application. Includes the MapView control 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.helloandroidimport android.app.Activityimport android.os.Bundlepublic class HelloAndroid extends Activity /** Called when the activity is first created. */ Override public subdue 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)

No comments:

Post a Comment

Note: Only a member of this blog may post a comment.