Presentation is loading. Please wait.

Presentation is loading. Please wait.

Mobile Programming Dr. Mohsin Ali Memon.

Similar presentations


Presentation on theme: "Mobile Programming Dr. Mohsin Ali Memon."— Presentation transcript:

1 Mobile Programming Dr. Mohsin Ali Memon

2 Static Application Resources and Context
Applications may need to store significant amounts of data to control their runtime behavior. Some of this data describes the application environment: the app name, the intents it registers, the permissions it needs and so on. This data is stored in a file called the manifest.

3 Resources Other data might be images to display or simple text strings, indicating what background color or font to use. These data are called resources. Together, all this information forms the context of the application, and Android provides access to it through the Context class.

4 Example Project explored

5 AndroidManifest.xml Example

6 Parameters of AndroidManifest.xml
uses-permission android:name=... The permission is requested when the application is installed. From then on, Android remembers that the user said it was OK (or not) to run this application and allow access to the secure features. intent-filter Here we declare an intent filter that tells Android when this Activity should run. When an app asks Android to fulfill an Intent, the runtime looks among the available activities

7 Resources Android applications place images, icons, and user interface layout files into a directory named res. The res directory usually will contain at least four subdirectories, as follows: Layout contains Android user interface XML files, Drawable contains drawing artifacts such as the application icon

8 Resources cont’d Raw Values
holds files that may be read as streams during execution of a program Values contains values that the application will read during execution, or string data. Applications access resources in these directories using the method context.getResources() and the R class

9 The Android Application Runtime Environment
Android’s unique application component architecture is, in part, a product of the way Android implements a multiprocessing environment. For multiple applications from multiple vendors with a minimal requirement to trust each vendor, Android executes multiple instances of the Dalvik VM, one for each task.

10 Dalvik VM Android’s approach to multiprocessing, using multiple processes and multiple instances of a VM, requires that each instance of the VM be space-efficient. This is achieved partly through the component life cycle, which enables objects to be garbage-collected and recreated, and partly by the VM itself.

11 Dalvik VM cont’d Android uses the Dalvik VM to run a bytecode system developed specifically for Android, called dex. Dex bytecodes are approximately twice as space-efficient as Java bytecodes, inherently halving the memory overhead of Java classes for each process.

12 Component Lifecycles Component life cycles have two purposes: they facilitate efficient use of each application’s memory, or heap space, and they enable the state of entire processes to be preserved and restored so that the Android system can run more applications than can fit in memory.

13 The Activity Lifecycle
It is one of the most complex life cycles. You need to select which life cycle callbacks you need to implement, and knowing when they are called. LTE (Long Term Evolution)

14 Example The runtime calls on onSaveInstanceState when it determines that it might have to destroy the activity, but may restore it later The user may save any state that will let the user continue using the application later.

15 Example cont’d This method is called when an activity that was destroyed is being recreated. The data saved in the previous instance of the activity, is passed to the new instance via onRestoreInstanceState

16 Introduction to Eclipse

17 Workspace Eclipse keeps a lot of state, and workspaces are where it is kept. When you first run Eclipse, it will ask if you want to create a workspace. By default, new projects are directories created inside the workspace directory.

18 Eclipse and Android The ADT plug-in adds several Android-specific tools to the Eclipse workbench. Most of these tools can be found in the Android perspective (Window→Open Perspective→ Other..., select DDMS). LogCat Displays the device logs in a scrolling pane. You can adjust filtering so that only the logs you are interested in are visible, or so that you can see everything down to the garbage collections and library loading. File Explorer Displays the file explorer.

19

20 Eclipse and Android cont’d
Heap Displays the heap. Threads Displays threads. Pixel Perfect Displays the Pixel Perfect view. Layout View Displays the layout view. avdmgr Displays the Android SDK and AVD Manager.

21 Android virtual Devices (AVDs)
When you installed the SDK or when you set up the ADT plug-in—you set up one or more Android Virtual Devices (AVDs) When you create a new Android project you associate it with one of the AVDs. The plug-in uses the appropriate profile to set up both the compilation environment and the emulator used for running the application

22 AVDs cont’d

23 AVDs cont’d

24 Application running on emulator

25 AVDs cont’d Name Target SD Card
This is the name of the AVD. You can use any name for an AVD, but a name that indicates which system image it uses is helpful. Target The Target parameter sets which system image will be used in this AVD. It should be the same as, or more recent than, the target you selected as the build target for Android project. SD Card Some applications require an SD card that extends storage beyond the flash memory built into an Android device. You can create a small virtual SD card of 100 MB in size, even though most phones are equipped with SD cards holding several gigabytes.

26 AVD’s cont’d


Download ppt "Mobile Programming Dr. Mohsin Ali Memon."

Similar presentations


Ads by Google