0% found this document useful (0 votes)
94 views

Mobile Programming: Engr. Waqar Ahmed

This document discusses key concepts in mobile programming such as activity lifecycles, application resources and context, the Android manifest file, and the Dalvik virtual machine. It also covers the Android software development kit, Android virtual devices, and the Android debug bridge tool.

Uploaded by

Sajid Ali
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
94 views

Mobile Programming: Engr. Waqar Ahmed

This document discusses key concepts in mobile programming such as activity lifecycles, application resources and context, the Android manifest file, and the Dalvik virtual machine. It also covers the Android software development kit, Android virtual devices, and the Android debug bridge tool.

Uploaded by

Sajid Ali
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 20

Mobile Programming

Engr. Waqar Ahmed

MUET, Shaheed Z.A Bhutto Campus Khairpur Mir’s


Activity Lifecycle
• It is one of the most complex life cycles.
• You need to select which life cycle callbacks you need to implement, a
nd knowing when they are called.
Activity Lifecycle
• 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.
Activity Lifecycle
• 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
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.


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.
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
Resources
• Raw
– 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
Android Manifest.xml Example
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.
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.
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 enable
s objects to be garbage-collected and recreated, and partly by the VM
itself.
Dalvik VM

• 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.
Component Lifecycle

• 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.
Android Studio
Software Development Kit (SDK)
• Android SDK Tools is a component for the Android SDK. It includes the
complete set of development and debugging tools for Android. It is
included with Android Studio
Android Virtual Devices (AVD)
• 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.
Android Virtual Devices (AVD)
Android Virtual Devices (AVD)
• Name
– 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.
Android Debug Bridge (ADB)
• Android Debug Bridge (ADB) is a versatile command-line tool that
lets you communicate with a device.

You might also like