Patel Group of Institutions MCA- Vth Semester Subject: Mobile Computing (650003) Q1) What is Android? Explain history of android. Q1) Write a note on OHA. Q1) What are different types Android platform available? Android is an operating system and a software platform upon which applications are developed. A core set of applications for everyday tasks, such as web browsing and email, are included on Android handsets. As a product of the OHA’s vision for a robust and open source development environment for wireless,Android is an emerging mobile development platform. The platform was designed for the sole purpose of encouraging a free and open market that all mobile applications phone users might want to have and software developers might want to develop. Open Handset Alliance With its user-centric, democratic design philosophies, Google has led a movement to turn the existing closely guarded wireless market into one where phone users can move between carriers easily and have unfettered access to applications and services. With its vast resources, Google has taken a broad approach, examining the wireless infrastructure from the FCC wireless spectrum policies to the handset manufacturers’ requirements, application developer needs, and mobile operator desires. Next, Google joined with other like-minded members in the wireless community and posed the following question: What would it take to build a better mobile phone? The Open Handset Alliance (OHA) was formed in November 2007 to answer that very question. The OHA is a business alliance comprised of many of the largest and most successful mobile companies on the planet. Its members include chip makers, handset manufacturers, software developers, and service providers. The entire mobile supply chain is well represented. The Open Handset Alliance (OHA) is a consortium of 86 hardware, software, and telecommunication companies devoted to advancing open standards for mobile devices. The OHA hopes to deliver a better mobile software experience for consumers by providing the platform needed for innovative mobile development at a faster rate and with higher quality than existing platforms, without licensing fees for either software developers or handset manufacturers. OHA(Open Handset Alliance) History: Andy Rubin has been credited as the father of the Android platform. His company, Android Inc., was acquired by Google in 2005.Working together, OHA members, including Google, began developing a nonproprietary open standard platform based upon technology developed at Android Inc. that would aim to alleviate the aforementioned problems hindering the mobile community. The result is the Android project. To this day, most Android platform development is completed by Rubin’s team at Google, where he acts as VP of Engineering and manages the Android platform roadmap. Google’s involvement in the Android project has been so extensive that the line between who takes responsibility for the Android platform (the OHA or Google) has blurred. Google hosts the Android open source project and provides online Android documentation, tools, forums, and the Software Development Kit (SDK) for developers. All major Android news originates at Google. The company has also hosted a number of events at conferences and the Android Developer Challenge (ADC). Different android platform The Android mascot is a little green robot; this little guy (girl?) is often used to depict Android-related materials. In Android’s case, the SDKs are named alphabetically after sweets the latest version of Android is codenamed Gingerbread. Android 1.0 SDK Astro September 23, 2008 Android 1.1 SDK Bender February 9, 2009 Created by: Prof. Adnan Ahmad (9979276001) Page 1 Patel Group of Institutions Subject: Mobile Computing (650003) Android 1.5 SDK Android 1.6 SDK Android 2.0/2.1 SDK Android 2.2.X SDK Android 2.3.X SDK Android 3.X SDK Android 4.0.X SDK Android 4.1.X SDK MCA- Vth Semester Cupcake April 30, 2009 Donut September 15, 2009 Éclair October 26, 2009 Froyo May 20, 2010 Gingerbread December 6, 2010 Honeycomb February 22, 2011 Ice Cream Sandwich October 19, 2011 Jelly Bean July 9, 2012 Q2) What is Android? List and explain feature of android platform. A software stack made up of the operating system (the platform on which everything runs), the middleware (the programming that allows applications to talk to a network and to one another), and the applications (the actual programs that the phones will run). Based on the Linux kernel Developed by Google and later the Open Handset Alliance (OHA) Allows writing managed code in the Java language Unveiling of the Android platform was announced on 5 November 2007 with the foundation of OHA Features of Android Handset layouts - Larger VGA, 2D graphics library, 3D graphics library based on OpenGL ES 2.0 specifications layout and traditional smart phone layouts. Storage – SQLite RDBMS Connectivity - including GSM/EDGE, CDMA, Bluetooth, Wi-Fi, NFC and WiMAX. Messaging – SMS, MMS, C2DM, GCM Web browser - based on the open-source WebKit layout engine, coupled with Chrome's V8 JavaScript engine Multi Language Support Java support – DVM, J2ME support with third party App Media support - WebM, H.263, H.264, AMR, AMR-WB, AAC, HE-AAC, MP3, MIDI, Ogg Vorbis, FLAC, WAV, JPEG, PNG, GIF, BMP, WebP Addition Hardware Support - video/still cameras, touch screens, GPS, accelerometers, gyroscopes, barometers, magnetometers, dedicated gaming controls, proximity and pressure sensors Multi-touch Video calling Multi Tasking Tethering Screen Capture External Storage Created by: Prof. Adnan Ahmad (9979276001) Page 2 Patel Group of Institutions Subject: Mobile Computing (650003) MCA- Vth Semester Q3) Draw diagram of android platform architecture. Android Platform Architecture Linux Kernel : Core services (including hardware drivers, process and memory management, security, network, and power management) are handled by a Linux 2.6 kernel. Libraries : Running on top of the kernel, Android includes various C/C++ core libraries such as libc and SSL, as well as: A media library for playback of audio and video media A Surface manager to provide display management Graphics libraries that include SGL and OpenGL for 2D and 3D graphics SQLite for native database support SSL and WebKit for integrated web browser and Internet security Android Run Time : The Android run time is the engine that powers your applications and, along with the libraries, forms the basis for the application framework. Core Libraries : The core Android libraries provide most of the functionality available in the core Java libraries as well as the Android-specific libraries. Dalvik Virtual Machine Dalvik is a register-based virtual machine that’s been optimized to ensure that a device can run multiple instances efficiently. It relies on the Linux kernel for threading and low-level memory management. One of the key elements of Android is the Dalvik virtual machine. Rather than use a traditional Java virtual machine (VM) such as Java ME (Java Mobile Edition), Android uses its own custom VM designed to ensure that multiple instances run efficiently on a single device. Application Framework : The application framework provides the classes used to create Android applications. It also provides a generic abstraction for hardware access and manages the user interface and application resources. Created by: Prof. Adnan Ahmad (9979276001) Page 3 Patel Group of Institutions Subject: Mobile Computing (650003) MCA- Vth Semester Application Layer : All applications, both native and third party, are built on the application layer using the same API libraries. The application layer runs within the Android run time using the classes and services made available from the application framework. Q4) Comment “Android is hailed as the first complete, open and free mobile platform. Android Platform Differences Android is hailed as “the first complete, open, and free mobile platform”: Complete: The designers took a comprehensive approach when they developed the Android platform.They began with a secure operating system and built a robust software framework on top that allows for rich application development opportunities. Open: The Android platform is provided through open source licensing. Developers have unprecedented access to the handset features when developing applications. Free: Android applications are free to develop. There are no licensing or royalty fees to develop on the platform. No required membership fees. No required testing fees. No required signing or certification fees. Android applications can be distributed and commercialized in a variety of ways. Q5) Explain Fundamentals components of Android Application. Q5) What are the importance android terminology? Context: The context is the central command center for an Android application.All application-specific functionality can be accessed through the context. Using the Application Context The application Context is the central location for all top-level application functionality.The Context class can be used to manage application-specific configuration details as well as application-wide operations and data. Use the application Context to access settings and resources shared across multiple Activity instances. Retrieving the Application Context You can retrieve the Context for the current process using the getApplicationContext() method, like this: Context context = getApplicationContext(); After you have retrieved a valid application Context, it can be used to access applicationwide features and services. Retrieving Application Resources You can retrieve application resources using the getResources() method of the application Context.The most straightforward way to retrieve a resource is by using its resource identifier, a unique number automatically generated within the R.java class. The following example retrieves a String instance from the application resources by its resource ID: String greeting = getResources().getString(R.string.hello); Intent : An intent generically defines an “intention” to do some work. You can use intents to perform the following tasks, for instance: Broadcast a message Start a service Launch an activity Display a web page or a list of contacts Dial a phone number or answer a phone call Open a file such as PDF Intents are not always initiated by your application—they’re also used by the system to notify your application of specific events. Activities : Its basically a java class that may represent a screen in the App. Your application’s presentation layer. An activity is a user interface concept. An activity usually represents a single screen in your application. It generally contains one or more views, but it doesn’t have to. Created by: Prof. Adnan Ahmad (9979276001) Page 4 Patel Group of Institutions Subject: Mobile Computing (650003) MCA- Vth Semester Services : Services in Android resemble services you see in Windows or other platforms—they’re background processes that can potentially run for a long time. Android defines two types of services: local services and remote services. (private and global service) Local services are components that are only accessible by the application that is hosting the service. Remote services are services that are meant to be accessed remotely by other applications running on the device. Content Provider : Data sharing among mobile applications on a device is common. Therefore, Android defines a standard mechanism for applications to share data (such as a list of contacts, manage and share application databases). Through content providers, you can expose your data and have your applications use data from other applications. View : The concept of a view in J2EE and Swing carries over to Android. Views are UI elements that form the basic building blocks of a user interface. Views are hierarchical and they know how to draw themselves. Q6) Write a brief note on following a. AVD b. SDK and AVD Manager c. ADB d. DDMS e. Emulator Android SDK and AVD Manager The Android SDK and AVD Manager facilitate Android development across multiple platform versions simultaneously. When a new Android SDK is released, you can use this tool to download and update your tools while still maintaining backward compatibility and use older versions of the Android SDK. The tool also manages the AVD configurations. To manage applications in the Android emulator, you must configure an AVD.This AVD profile describes what type of device you want the emulator to simulate, including which Android platform to support. You can specify different screen sizes and orientations, and you can specify whether the emulator Has an SD card. Android Virtual Device (AVD) The Android emulator is a not a real device, but a generic Android system simulator for testing purposes. Developers can simulate different types of Android devices by creating Android Virtual Device (AVD) configurations. Using AVD configurations, Android emulators can simulate Different target platform versions Different screen sizes and resolutions Different input methods Different underlying hardware configurations Different external storage configurations Each emulator configuration is unique, as described within its AVD and stores its data persistently on its emulated SD card. Android Emulator The Android emulator, shown in Figure, is one of the most important tools provided with the Android SDK.You will use this tool frequently when designing and developing Android applications.The emulator runs on your computer and behaves much as a mobile device would.You can load Android applications into the emulator, test, and debug them. Created by: Prof. Adnan Ahmad (9979276001) Page 5 Patel Group of Institutions Subject: Mobile Computing (650003) MCA- Vth Semester The emulator is a generic device and is not tied to any one specific phone configuration. You describe the hardware and software configuration details that the emulator is to simulate by providing an AVD configuration. Dalvik Debug Monitor Server (DDMS) The Dalvik Debug Monitor Server (DDMS) is a command-line tool that has also been integrated into Eclipse as a perspective (see Figure 2.7).This tool provides you with direct access to the device—whether it’s the emulator virtual device or the physical device. You use DDMS to view and manage processes and threads running on the device, view heap data, attach to processes to debug, and a variety of other tasks. Whether you use DDMS from Eclipse or as a stand-alone tool, be aware of a few key features: A list of running emulators and connected devices displays in the top-left corner. The File Explorer enables you to browse files on the emulator or device (including application files, directories, and databases) and pull and push files to the Android system. The LogCat window enables you to monitor the Android Logging console (LogCat).This is where calls to Log.i(), Log.e(), and other Log messages display. You can inspect individual processes (heap and thread updates).You can inspect individual threads. You can kill processes. You can prompt garbage collection on a process and then view the Heap for that application. You can track application memory allocation using the Allocation Tracker pane. You can take remote screenshots of the emulator or the device using the Screen Capture button. You have some helpful Emulator console functionality at your fingertips, such as the ability to send GPS information and to simulate incoming calls and SMS messages. Android Debug Bridge (ADB) The Android Debug Bridge (ADB) is a client-server tool used to enable developers to debug Android code on the emulator and the device using a standard Java IDE such as Eclipse. The DDMS and the Android Development PlugIn for Eclipse both use the ADB to facilitate interaction between the development environment and the device (or Emulator). Developers can also use ADB to interact with the device file system, install Android application manually, and issue shell commands. For example, the sqlite3 shell commands enable you to access device database the Android Debug Bridge (ADB) is a client-server tool that interacts directly with Android devices and emulators using a command-line interface. You can use ADB to list all Android devices and emulator instances connected to a development machine. To do this, simply use the devices command of the adb command line. For example adb devices This command lists the emulators and devices attached to this machine by their serial number and state (offline or device). For emulator instances, the serial number is based on their unique port number. For example, in this case,we have one emulator instance (Port 5554) and one Android device: When you know the serial number of the device you want to connect to, you can issue commands as follows: adb –s <serial number> <command> For example, to get the state of a specific device, type adb -s emulator-5554 get-state Created by: Prof. Adnan Ahmad (9979276001) Page 6 Patel Group of Institutions Subject: Mobile Computing (650003) MCA- Vth Semester Q7) What are resources? List default android resource directory. How to use Image resource programmatically? All Android applications are composed of two things: functionality (code instructions) and data (resources).The functionality is the code that determines how your application behaves. This includes any algorithms that make the application run. Resources include text strings, images and icons, audio files, videos, and other data used by the application. Storing Application Resources Android resource files are stored separately from the java class files in the Android project. Most common resource types are stored in XML.You can also store raw data files and graphics as resources. Resources are organized in a strict directory hierarchy within the Android project. All resources must be stored under the /res project directory in specially named subdirectories that must be lowercase. Each resource type corresponds to a specific resource subdirectory name. For example, all graphics are stored under the /res/drawable directory structure. Resources can be further organized in a variety of ways using even more specially named directory qualifiers. For example, the /res/drawable-hdpi directory stores graphics for high-density screens, the /res/drawable-ldpi directory stores graphics for low-density screens. How Important Resource Types Are Stored in Android Project Resource Directories ResourceType Required Directory Filename XML Tag Strings /res/values/ strings.xml (suggested) <string> Arrays of Strings /res/values/ strings.xml (suggested) <string-array>, <item> Booleans /res/values/ bools.xml (suggested) <bool> Integers /res/values/ integers.xml <integer> Colors /res/values/ Colors.xml (suggested) <color> Dimensions /res/values/ Dimens.xml (suggested) <dimen> SimpleDrawables Paintable) /res/values/ drawables.xml <drawable> Graphics /res/drawable/ Examples include <shape> icon.png logo.jpg Menus /res/menu/ mainmenu.xml <menu> Raw Files /res/raw/ jingle.mp3 somevideo.mp4 Defined by the developer. Layouts /res/layout/ main.xml layout control Frame-by-Frame Animations /res/drawable/ sequence1.xml <animation-list>,<item> Tweened Animations /res/anim/ fadesequence.xml <set>, <alpha>, <scale>, <translate> <rotate> Q8) Explain the following color formats. a. #RGB b. #ARGB c. #RRGGBB d. #AARRGGBB Android applications can store RGB color values, which can then be applied to other screen elements. You can use these values to set the color of text or other elements, such as the screen background. Color resources are defined in XML under the /res/values project directory and compiled into the application package at build time. RGB color values always start with the hash symbol (#).The alpha value can be given for transparency control. The following color formats are supported: Created by: Prof. Adnan Ahmad (9979276001) Page 7 Patel Group of Institutions Subject: Mobile Computing (650003) MCA- Vth Semester #RGB (example, #F00 is 12-bit color, red) #ARGB (example, #8F00 is 12-bit color, red with alpha 50%) #RRGGBB (example, #FF00FF is 24-bit color, magenta) #AARRGGBB (example, #80FF00FF is 24-bit color, magenta with alpha 50%) Color values are appropriately tagged with the <color> tag and represent a name-value pair. Here’s an example of a simple color resource file /res/values/colors.xml: <?xml version=”1.0” encoding=”utf-8”?> <resources> <color name=”background_color”>#006400</color> <color name=”text_color”>#FFE4C4</color> </resources> Color resources are simply integers.The following code retrieves a color resource called prettyTextColor: int myResourceColor = getResources().getColor(R.color.prettyTextColor); Q9) What is the use of the strings.xml file? String resources are among the simplest resource types available to the developer. String resources might show text labels on form views and for help text.The application name is also stored as a string resource, by default. String resources are defined in XML under the /res/values project directory and compiled into the application package at build time. All strings with apostrophes or single straight quotes need to be escaped or wrapped in double straight quotes. Some examples of well-formatted string values are shown . String Resource Formatting Examples String Resource Value Displays As Hello, World Hello, World “User’s Full Name:” User’s Full Name: User\’s Full Name: User’s Full Name: She said \”Hi.\ ” She said,“ Hi.” She\’s busy but she did say, she’s busy but she did say, \”Hi.\” “Hi.” You can edit the strings.xml file using the Resources tab, or you can edit the XML directly by clicking the file and choosing the strings.xml tab.After you save the file, the resources are automatically added to your R.java class file. String values are appropriately tagged with the <string> tag and represent a namevalue Pair Here’s an example of the string resource file /res/values/strings.xml: <?xml version=”1.0” encoding=”utf-8”?> <resources> <string name=”app_name”>Resource Viewer</string> <string name=”test_string”>Testing 1,2,3</string> <string name=”test_string2”>Testing 4,5,6</string> </resources> Bold, Italic, and Underlined Strings You can also add three HTML-style attributes to string resources.These are bold, italic, and underlining. You specify the styling using the <b>, <i>, and <u> tags. For example <string name=”txt”><b>Bold</b>,<i>Italic</i>,<u>Line</u></string> Q10) Give the list image formats supported in Android Applications often include visual elements such as icons and graphics. Android supports several image formats that can be directly included as resources for your application. Adding image resources to your project is easy. Simply drag the image asset into the/res/drawable directory and it is automatically included in the application package at Build time. Created by: Prof. Adnan Ahmad (9979276001) Page 8 Patel Group of Institutions MCA- Vth Semester Subject: Mobile Computing (650003) Image Formats Supported in Android Supported Image Portable Network Graphics (PNG) Nine-Patch Stretchable Images Joint Photographic Experts Group (JPEG) Graphics Interchange Format (GIF) Format Description Required Preferred Format (Lossless) Preferred Format (Lossless) Acceptable Format (Lossy) Discouraged Format Extension .png .9.png .jpg, .jpeg .gif These image formats are all well supported by popular graphics editors such as Adobe Photoshop, GIMP, and Microsoft Paint. The Nine-Patch Stretchable Graphics can be created from PNG files using the draw9patch tool included with the Android SDK under the /tools directory. Q11) Explain String Arrays and Dimensions Tag. Working with String Arrays You can specify lists of strings in resource files.This can be a good way to store menu options and drop-down list values. String arrays are defined in XML under the /res/values project directory and compiled into the application package at build time. String arrays are appropriately tagged with the <string-array> tag and a number of <item> child tags, one for each string in the array. Here’s an example of a simple array resource file /res/values/arrays.xml: <?xml version=”1.0” encoding=”utf-8”?> <resources> <string-array name=”flavors”> <item>Vanilla Bean</item> <item>Chocolate Fudge Brownie</item> <item>Strawberry Cheesecake</item> <item>Coffee, Coffee, Buzz Buzz Buzz</item> <item>Americone Dream</item> </string-array> <string-array name=”soups”> <item>Vegetable minestrone</item> <item>New England clam chowder</item> <item>Organic chicken noodle</item> </string-array> </resources> accessing string arrays resources is easy. The following code retrieves a string array named flavors: String[] aFlavors = getResources().getStringArray(R.array.flavors); Working with Dimensions Many user interface layout controls such as text controls and buttons are drawn to specific dimensions. These dimensions can be stored as resources. Dimension values always end with a unit of measurement tag. Dimension values are appropriately tagged with the <dimen> tag and represent a namevalue pair. Dimension resources are defined in XML under the /res/values project directory and compiled into the application package at build time. The dimension units supported are shown. Dimension Unit Measurements Supported Unit ofMeasurement Description ResourceTagRequired Example Pixels Actual screen pixels px 20px Inches Physical measurement in 1in Millimeters Physical measurement mm 1mm Created by: Prof. Adnan Ahmad (9979276001) Page 9 Patel Group of Institutions MCA- Vth Semester Subject: Mobile Computing (650003) Points Screen density Scale independent pixels Common font measurement unit Pixels relative to 160dpi screen Best for scalable font display pt dp sp 14pt 1dp 14sp Here’s an example of a simple dimension resource file /res/values/dimens.xml: <?xml version=”1.0” encoding=”utf-8”?> <resources> <dimen name=”FourteenPt”>14pt</dimen> <dimen name=”OneInch”>1in</dimen> <dimen name=”TenMillimeters”>10mm</dimen> <dimen name=”TenPixels”>10px</dimen> </resources> Dimension resources are simply floating point values.The following code retrieves a dimension resource called textPointSize: float myDimension =getResources().getDimension(R.dimen.textPointSize); Q12) Explain all Android Project Files and Directories. Important Android Project Files and Directories Android File General Description AndroidManifest.xml Global application description file. It defines your application’s capabilities and permissions and how it runs. default. properties Automatically created project file. It defines your application’s build target and other build system options, as required. src Folder Required folder where all source code for the application resides. src/com.androidbook.myfirstandroidapp/ MyFirstAndroidAppActivity.java Core source file that defines the entry point of your Android application. gen Folder Required folder where auto-generated resource files for the application reside. gen/com.androidbook.myfirstandroidapp/ R.java Application resource management source file generated for you; it should not be edited. res Folder Required folder where all application resources are managed. Application resources include animations, drawable image assets, layout files, XML files, data resources such as strings, and raw files. res/drawable-*/icon.png Resource folders that store different resolutions of the application icon. res/layout/main.xml res/values/strings.xml assets Folder Single screen layout file. Application string resources. Folder where all application assets are stored. Application assets are pieces of application data (files, directories) that you do not want managed as application resources Created by: Prof. Adnan Ahmad (9979276001) Page 10 Patel Group of Institutions MCA- Vth Semester Subject: Mobile Computing (650003) Q13) What is Activity Stack? How to android platform manage various activity? Activity: An Android application is a collection of tasks, each of which is called an Activity. Each Activity within an application has a unique task or purpose. Performing Application Tasks with Activities The Android Activity class (android.app.Activity) is core to any Android application. Much of the time, you define and implement an Activity class for each screen in your application. For example, a simple game application might have the following five Activities, as shown below A Startup or Splash screen: This activity serves as the primary entry point to the application. It displays the application name and version information and transitions to the Main menu after a short interval. A Main Menu screen: This activity acts as a switch to drive the user to the core Activities of the application. Here the users must choose what they want to do within the application. A Game Play screen: This activity is where the core game play occurs. A High Scores screen: This activity might display game scores or settings. A Help/About screen: This activity might display the information the user might need to play the game. Startup/Splash Activity Main Menu Activity High Scores Activity Game Play Activity Help/About Activity Simple game with Five Activity Android Activity Stack Android applications can be multi-process, and the Android operating system allows multiple applications to run concurrently, provided memory and processing power is available. Applications can have background processes, and applications can be interrupted and paused when events such as phone calls occur. There can be only one active application visible to the user at a time—specifically, a single application Activity is in the foreground at any given time. The Android operating system keeps track of all Activity objects running by placing them on an Activity stack. When a new Activity starts, the Activity on the top of the stack (the current foreground Activity) pauses, and the new Activity pushes onto the top of the stack. When that Activity finishes, that Activity is removed from the activity stack, and the previous Activity in the stack resumes. I am the top activity. User can see and interact with me I am second activity in the stack. If the user hit back to top activity then user can see and interact with me. I am activity in the middle of the stack .User cannot see and interact with me Until everyone above me is destroyed. I am activity at the bottom of the stack. If those activity above me use too Many resources I will be destroyed. The Activity Stack Created by: Prof. Adnan Ahmad (9979276001) Page 11 Patel Group of Institutions Subject: Mobile Computing (650003) MCA- Vth Semester Q14) Explain Life Cycle of android application Activity with diagram. Using Activity Callbacks to Manage Application State and Resources Different important state changes within the Activity lifecycle are punctuated by a series of important method callbacks. These callbacks are shown in Figure. Here are the method stubs for the most important callbacks of the Activity class: public class MyActivity extends Activity { protected void onCreate(Bundle savedInstanceState); protected void onStart(); protected void onRestart(); protected void onResume(); protected void onPause(); protected void onStop(); protected void onDestroy(); } Initializing Static Activity Data in onCreate() When an Activity first starts, the onCreate() method is called.The onCreate() method has a single parameter, a Bundle, which is null if this is a newly started Activity. If this Activity was killed for memory reasons and is now restarted, the Bundle contains the previous state information for this Activity so that it can reinitiate. It is appropriate to perform any setup, such as layout and data binding, in the onCreate() method.This includes calls to the setContentView() method. Initializing and Retrieving Activity Data in onResume() Created by: Prof. Adnan Ahmad (9979276001) Page 12 Patel Group of Institutions Subject: Mobile Computing (650003) MCA- Vth Semester When the Activity reaches the top of the activity stack and becomes the foreground process, the onResume() method is called.Although the Activity might not be visible yet to the user, this is the most appropriate place to retrieve any instances to resources (exclusive or otherwise) that the Activity needs to run. Stopping, Saving, and Releasing Activity Data in onPause() When another Activity moves to the top of the activity stack, the current Activity is informed that it is being pushed down the activity stack by way of the onPause() method. Here, the Activity should stop any audio, video, and animations it started in the onResume() method.This is also where you must deactivate resources such as database Cursor objects if you have opted to manage them manually, as opposed to having them managed automatically. Destroy Static Activity Data in onDestroy() When an Activity is being destroyed, the onDestroy() method is called.The onDestroy() method is called for one of two reasons:The Activity has completed its lifecycle voluntarily, or the Activity is being killed by the Android operating system because it needs the resources. If the Activity is killed after onPause(), the onStop() and onDestroy() methods might not be called.The more resources released by an Activity in the onPause() method, the less likely the Activity is to be killed while in the background. The act of killing an Activity does not remove it from the activity stack. Instead, the Activity state is saved into a Bundle object, assuming the Activity implements and uses onSaveInstanceState() for custom data, though some View data is automatically saved. Q15) List and explain 3 methods of Log class. Android logging features are in the Log class of the android.util package. Some helpful methods in the android.util.Log class are following: Method Log.e() Log.w() Log.i() Log.d() Log.v() Purpose Log errors Log warnings Log informational messages Log Debug messages Log Verbose mesages First, you must add the appropriate import statement for the Log class: import android.util.Log; within the onCreate() method, you can log something informational: Log.i(DEBUG_TAG, “Info about MyFirstAndroidApp”); Q16) What is AndroidManifest.xml file? What kind of information is stored in it? Explain structure of it. Q16) What is the manifest file resource? Explain different tag available in manifest file. AndroidManifest.xml, which is similar to the web.xml file in the J2EE world, defines the contents and behavior of your application. For example, it lists your app’s activities and services, along with the permissions the application needs to run. The Eclipse manifest file resource editor organizes the manifest information into categories presented on five tabs: Manifest Application Permissions Instrumentation AndroidManifest.xml Created by: Prof. Adnan Ahmad (9979276001) Page 13 Patel Group of Institutions Subject: Mobile Computing (650003) MCA- Vth Semester Using the Manifest Tab The Manifest tab (Below Figure) contains package-wide settings, including the package name, version information, and minimum Android SDK version information. You can also set any hardware configuration requirements here. Using the Application Tab The Application tab (Below Figure) contains application-wide settings, including the application label and icon, as well as information about application components such as activities, intent filters, and other application functionality, including configuration for service and content provider implementations. Using the Permissions Tab The Permissions tab (Below Figure) contains any permission rules required by the application. This tab can also be used to enforce custom permissions created for the application. Using the Instrumentation Tab You can use the Instrumentation tab (Below Figure) to declare any instrumentation classes for monitoring the application. In the Name field, you fill in the fully qualified class name of the Instrumentation subclass for your application, and for Target Package, you provide the name of the package whose manifest file contains the <application> tag for the application to be monitored. Using the AndroidManifest.xml Tab The Android manifest file is a specially formatted XML file. You can edit the XML manually in the AndroidManifest.xml tab of the manifest file resource editor the file has a single <manifest> tag, within which all the package-wide settings appear. Within this tag is one <application> tag, which defines the specific application, with its single activity, with an Intent filter. In addition, the <uses-sdk> tag is also set. <?xml version="1.0" encoding="utf-8"?> <manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.androidbook.multimedia" android:versionCode="1" android:versionName="1.0"> <application android:icon="@drawable/icon" android:label="@string/app_name" android:debuggable="true"> <activity android:name=".MultimediaMenuActivity" android:label="@string/app_name"> <intent-filter> <action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.LAUNCHER" /> </intent-filter> </activity> <activity android:name="AudioActivity"></activity> OR <activity android:name=”.AudioActivity” /> </application> <uses-permission android:name="android.permission.SET_WALLPAPER" /> <uses-permission android:name="android.permission.CAMERA"></uses-permission> <uses-sdk android:minSdkVersion="3" android:targetSdkVersion="8"> </uses-sdk> <uses-feature android:name="android.hardware.camera" /> </manifest> Created by: Prof. Adnan Ahmad (9979276001) Page 14 Patel Group of Institutions Subject: Mobile Computing (650003) MCA- Vth Semester Q17) What is the use of <activity> tag and <intent-filter> tag. <activity> tag Each Activity within the application must be defined within the Android manifest file with an <activity> tag. For example, the following XML excerpt defines an Activity class called AudioActivity: <activity android:name="AudioActivity" /> This Activity must be defined as a class within the com.androidbook.multimedia package.That is, the package specified in the <manifest> element of the Android manifest file.You can also enforce scope of the activity class by using the dot as a prefix in the Activity name: <activity android:name=".AudioActivity" /> Or you can specify the complete class name: <activity android:name="com.androidbook.multimedia.AudioActivity" /> <intent-filter> tag An Activity class can be designated as the primary entry point by configuring an intent filter using the Android manifest tag <intent-filter> in the application’s AndroidManifest.xml file with the MAIN action type and the LAUNCHER category. The Android operating system uses Intent filters to resolve implicit intents. Intent filters can be applied to Activities, Services, and BroadcastReceivers.The filter declares that this component is open to receiving any Intent sent to the Android operating system that matches its criteria. <activity android:name=".MultimediaMenuActivity" android:label="@string/app_name"> <intent-filter> <action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.LAUNCHER" /> </intent-filter> </activity> Q18) Explain animation supported by Android taking suitable example. Q18) Explain the Different tweening Transformation. Q18) Explain different types of transformation in tweened animation. Android supports frame-by-frame animation and tweening. Frame-by-frame animation involves the display of a sequence of images in rapid succession.Tweened animation involves applying standard graphical transformations such as rotations and fades upon a singleimage. The Android SDK provides some helper utilities for loading and using animation resources. These utilities are found in the android.view.animation.AnimationUtils class. Defining and Using Frame-by-Frame Animation Resources Frame-by-frame animation is often used when the content changes from frame to frame. This type of animation can be used for complex frame transitions—much like a kid’s flip-book. To define frame-by-frame resources, take the following steps: 1. Save each frame graphic as an individual drawable resource. It may help to name your graphics sequentially, in the order in which they are displayed—for example, frame1.png, frame2.png, and so on. 2. Define the animation set resource in an XML file within /res/drawable/ resource directory. 3. Load, start, and stop the animation programmatically. Here’s an example of a simple frame-by-frame animation resource file /res/drawable/juggle.xml that defines a simple three-frame animation. <?xml version=”1.0” encoding=”utf-8” ?> <animation-list xmlns:android=”http://schemas.android.com/apk/res/android” android:oneshot=”false”> Created by: Prof. Adnan Ahmad (9979276001) Page 15 Patel Group of Institutions Subject: Mobile Computing (650003) MCA- Vth Semester <item android:drawable=”@drawable/splash1” android:duration=”50” /> <item android:drawable=”@drawable/splash2” android:duration=”50” /> <item android:drawable=”@drawable/splash3” android:duration=”50” /> </animation-list> Frame-by-frame animation set resources defined with <animation-list> are represented by the Drawable subclass AnimationDrawable.The following code retrieves an Animation Drawable resource called juggle: import android.graphics.drawable.AnimationDrawable; ... AnimationDrawable jugglerAnimation = (AnimationDrawable)getResources(). getDrawable(R.drawable.juggle); To begin the animation,we call the start() method: jugglerAnimation.start(); We can end our animation at any time using the stop() method: jugglerAnimation.stop(); Defining and Using Tweened Animation Resources Tweened animation features include scaling, fading, rotation, and translation. These actions can be applied simultaneously or sequentially and might use different interpolators. Graphic animation sequences can be stored as specially formatted XML files in the /res/anim directory and are compiled into the application binary at build time. Here’s an example of a simple animation resource file /res/anim/spin.xml that defines a simple rotate operation— rotating the target graphic counterclockwise four times in place, taking 10 seconds to complete: <?xml version=”1.0” encoding=”utf-8” ?> <set xmlns:android =”http://schemas.android.com/apk/res/android” android:shareInterpolator=”false”> <set> <rotate android:fromDegrees=”0” android:toDegrees=”-1440” android:pivotX=”50%” android:pivotY=”50%” android:duration=”10000” /> </set> </set> If we go back to the example of a BitmapDrawable earlier,we can now add some animation simply by adding the following code to load the animation resource file spin.xml and set the animation in motion: import android.view.animation.Animation; import android.view.animation.AnimationUtils; import android.widget.ImageView; ... ImageView flagImageView =(ImageView)findViewById(R.id.ImageView01); flagImageView.setImageResource(R.drawable.flag); ... Animation an =AnimationUtils.loadAnimation(this, R.anim.spin); Created by: Prof. Adnan Ahmad (9979276001) Page 16 Patel Group of Institutions Subject: Mobile Computing (650003) MCA- Vth Semester flagImageView.startAnimation(an); Now you have your graphic spinning. Notice that we loaded the animation using the base class object Animation.You can also extract specific animation types using the subclasses that match: RotateAnimation, ScaleAnimation, TranslateAnimation, and AlphaAnimation. Exploring the Four Different Tweening Transformations Now let’s look at each of the four types of tweening transformations individually.These types are Transparency changes (Alpha) Rotations (Rotate) Scaling (Scale) Movement (Translate) Working with Alpha Transparency Transformations Transparency is controlled using Alpha transformations.Alpha transformations can be used to fade objects in and out of view or to layer them on the screen. Alpha values range from 0.0 (fully transparent or invisible) to 1.0 (fully opaque or visible). Alpha animations involve a starting transparency (fromAlpha) and an ending transparency (toAlpha). The following XML resource file excerpt defines a transparency-change animation, taking five seconds to fade in from fully transparent to fully opaque: <alpha android:fromAlpha=”0.0” android:toAlpha=”1.0” android:duration=”5000”> </alpha> Working with Rotating Transformations You can use rotation operations to spin objects clockwise or counterclockwise around a pivot point within the object’s boundaries. The following XML resource file excerpt defines a rotation animation, taking five seconds to make one full clockwise rotation, pivoting from the center of the object: <rotate android:fromDegrees=”0” android:toDegrees=”360” android:pivotX=”50%” android:pivotY=”50%” android:duration=”5000” /> Working with Scaling Transformations You can use scaling operations to stretch objects vertically and horizontally. Scaling operations are defined as relative scales.Think of the scale value of 1.0 as 100 percent, or fullsize. To scale to half-size, or 50 percent, set the target scale value of 0.5. <scale android:pivotX=”50%” android:pivotY=”50%” android:fromXScale=”1.0” android:fromYScale=”1.0” android:toXScale=”2.0” android:toYScale=”2.0” android:duration=”5000” /> Programmatically, you can create this same animation using the ScaleAnimation class within the android.view.animation package. Created by: Prof. Adnan Ahmad (9979276001) Page 17 Patel Group of Institutions Subject: Mobile Computing (650003) MCA- Vth Semester Working with Moving Transformations You can move objects around using translate operations.Translate operations move an object from one position on the (x,y) coordinate to another coordinate. To perform a translate operation, you must specify the change, or delta, in the object’s coordinates.You can set four values for translations: starting position (fromXDelta, fromYDelta) and relative target location (toXDelta, toYDelta). <translate android:toYDelta=”-100” android:fillAfter=”true” android:duration=”2500” /> Programmatically, you can create this same animation using the TranslateAnimation class within the android.view.animation package. Q19) What is interpolator? List and explain different interpolator. Working with Different Interpolators The animation interpolator determines the rate at which a transformation happens in time.There are a number of different interpolators provided as part of the Android SDK framework. Some of these interpolators include AccelerateDecelerateInterpolator: Animation starts slowly, speeds up, and ends slowly AccelerateInterpolator: Animation starts slowly and then accelerates AnticipateInterpolator: Animation starts backward, and then flings forward AnticipateOvershootInterpolator: Animation starts backward, flings forward, overshoots its destination, and then settles at the destination BounceInterpolator: Animation “bounces” into place at its destination CycleInterpolator: Animation is repeated a certain number of times smoothly transitioning from one cycle to the next DecelerateInterpolator: Animation begins quickly, and then decelerates LinearInterpolator: Animation speed is constant throughout OvershootInterpolator: Animation overshoots its destination, and then settles at the destination Q20) Write detailed note on different types of layouts Q20) Write a note on different types of Layout available in android. (Purpose, tag, major attribute, xml file code example, screen design, when it is more suitable). Android Layout One special type of control found within the android.widget package is called a layout. A layout control is still a View object, but it doesn’t actually draw anything specific on the screen. Instead, it is a parent container for organizing other controls (children). Layout controls determine how and where on the screen child controls are drawn. Each type of layout control draws its children using particular rules. For instance, the LinearLayout control draws its child controls in a single horizontal row or a single vertical column. Android provides a simple way to create layout files inXML as resources provided in the /res/layout project directory Types of Layouts: LinearLayout: Organizes its children either horizontally or vertically. TableLayout: Organizes its children in tabular form. RelativeLayout : Organizes its children relative to one another or to the parent. AbsoluteLayout : Positions children based on exact coordinates. FrameLayout : Allows you to dynamically change the control in the layout. LinearLayout : LinearLayout is used when we need to arrange the widgets/views in a horizontal or vertical manner. The direction of arrangement can be set to horizontal or vertical, by default it is being horizontal. <?xml version=”1.0” encoding=”utf-8”?> Created by: Prof. Adnan Ahmad (9979276001) Page 18 Patel Group of Institutions Subject: Mobile Computing (650003) MCA- Vth Semester <LinearLayout xmlns:android= “http://schemas.android.com/apk/res/android” android:orientation=”vertical” android:layout_width=”fill_parent” android:layout_height=”fill_parent” > <TextView android:layout_width=”fill_parent” android:layout_height=”wrap_content” android:text=”@string/hello” /> </LinearLayout> Creating only an XML file, though,won’t actually draw anything on the screen.A particular layout is usually associated with a particular Activity. In your default Android project, there is only one activity, which sets the main.xml layout by default.To associate the main.xml layout with the activity, use the method call setContentView() with the identifier of the main.xml layout. setContentView(R.layout.main); Creating Layouts Programmatically(Custom Layout) public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); TextView text1 = new TextView(this); text1.setText(“Hi there!”); TextView text2 = new TextView(this); text2.setText(“I’m second. I need to wrap.”); text2.setTextSize((float) 60); LinearLayout ll = new LinearLayout(this); ll.setOrientation(LinearLayout.VERTICAL); ll.addView(text1); ll.addView(text2); setContentView(ll); } The onCreate() method is called when the Activity is created.The first thing this method does is some normal Activity housekeeping by calling the constructor for the base class. Relative Layout: Using the Relative Layout, you can define the positions of each of the child Views relative to each other and the screen boundaries. <?xml version=”1.0” encoding=”utf-8”?> <RelativeLayout xmlns:android= “http://schemas.android.com/apk/res/android” android:id=”@+id/RelativeLayout01” android:layout_height=”fill_parent” android:layout_width=”fill_parent”> <Button android:id=”@+id/ButtonCenter” android:text=”Center” android:layout_width=”wrap_content” android:layout_height=”wrap_content” android:layout_centerInParent=”true” /> <ImageView android:id=”@+id/ImageView01” android:layout_width=”wrap_content” android:layout_height=”wrap_content” Created by: Prof. Adnan Ahmad (9979276001) Page 19 Patel Group of Institutions Subject: Mobile Computing (650003) MCA- Vth Semester android:layout_above=”@id/ButtonCenter” android:layout_centerHorizontal=”true” android:src=”@drawable/arrow” /> </RelativeLayout> TableLayout : If the Layout's widgets/views need to be arranged in the form of rows and columns, we use this layout object. This is similar to html tables. The cells can span columns. The TableLayout do not display its border. <TableLayout xmlns:android= “http://schemas.android.com/apk/res/android” android:id=”@+id/TableLayout01” android:layout_width=”fill_parent” android:layout_height=”fill_parent” android:stretchColumns=”*”> <TableRow android:id=”@+id/TableRow01”> <Button android:id=”@+id/ButtonLeft” android:text=”Left Door” /> <Button android:id=”@+id/ButtonMiddle” android:text=”Middle Door” /> <Button android:id=”@+id/ButtonRight” android:text=”Right Door” /> </TableRow> <TableRow android:id=”@+id/TableRow02”> <Button android:id=”@+id/ButtonBack” android:text=”Go Back” android:layout_column=”1” /> </TableRow> </TableLayout> Frame Layout: The simplest of the Layout Managers, the Frame Layout simply pins each child view to the top left corner. Adding multiple children stacks each new child on top of the previous, with each new View obscuring the last. <FrameLayout xmlns:android= http://schemas.android.com/apk/res/android android:id=”@+id/FrameLayout01” android:layout_width=”wrap_content” android:layout_height=”wrap_content” android:layout_gravity=”center”> <ImageView android:id=”@+id/ImageView01” android:layout_width=”wrap_content” android:layout_height=”wrap_content” android:src=”@drawable/green_rect” android:minHeight=”200px” android:minWidth=”200px” /> Created by: Prof. Adnan Ahmad (9979276001) Page 20 Patel Group of Institutions Subject: Mobile Computing (650003) MCA- Vth Semester <ImageView android:id=”@+id/ImageView02” android:layout_width=”wrap_content” android:layout_height=”wrap_content” android:src=”@drawable/red_oval” android:minHeight=”100px” android:minWidth=”100px” android:layout_gravity=”center” /> </FrameLayout> AbsoluteLayout : When there is a need is to specify exact x and y co-ordinate position of the view, then AbsoluteLayout need to be used. This layout is difficult to maintain. Q21) Write notes of view class. (Its attributes and methods). Define View and View Group. Introducing the Android View The Android SDK has a Java packaged named android.view.This package contains a number of interfaces and classes related to drawing on the screen. However, when we refer to the View object,we actually refer to only one of the classes within this package: the android.view.View class. The View class is the basic user interface building block within Android. It represents a rectangular portion of the screen.The View class serves as the base class for nearly all the user interface controls and layouts within the Android SDK. <?xml version=”1.0” encoding=”utf-8”?> <LinearLayout xmlns:android= “http://schemas.android.com/apk/res/android” android:orientation=”vertical” android:layout_width=”fill_parent” android:layout_height=”fill_parent” > <TextView android:layout_width=”fill_parent” android:layout_height=”wrap_content” android:text=”@string/hello” /> </LinearLayout> Understanding View versus ViewGroup Like other View objects, ViewGroup controls representa rectangle of screen space.What makes ViewGroup different from your typical control is that ViewGroup objects contain other View objects.A View that contains other View objects is called a parent view.The parent View contains View objects called child views, or children. You add child View objects to a ViewGroup programmatically using the method addView(). In XML, you add child objects to a ViewGroup by defining the child View control as a child node in the XML (within the parent XML element, as we’ve seen various times using the LinearLayout ViewGroup). ViewGroup subclasses are broken down into two categories: Layout classes View container controls Created by: Prof. Adnan Ahmad (9979276001) Page 21 Patel Group of Institutions Subject: Mobile Computing (650003) MCA- Vth Semester Q22) What are Layout classes? What are the built-in View Container classes? Explain any one.Using Built-In View Container Classes Q22) List the data driven containers. For what purpose ListView control is used? Which is the base class and list the methods available? About Layout refer above question no. 20 Layouts are not the only controls that can contain other View objects.Although layouts are useful for positioning other View objects on the screen, they aren’t interactive.Now let’s talk about the other kind of ViewGroup: the containers.These View objects encapsulate other, simpler View types and give the user some interactive ability to browse the child View objects in a standard fashion. Much like layouts, these controls each have a special, Well-defined purpose. The types of ViewGroup containers built-in to the Android SDK framework include Lists, grids, and galleries Switchers with ViewFlipper, ImageSwitcher, and TextSwitcher Tabs with TabHost and TabControl Scrolling with ScrollView and HorizontalScrollView Hiding and showing content with the SlidingDrawer Using Data-Driven Containers Some of the View container controls are designed for displaying repetitive View objects in a particular way. Examples of this type of View container control include ListView, GridView, and GalleryView: ListView: Contains a vertically scrolling, horizontally filled list of View objects, each of which typically contains a row of data; the user can choose an item to perform some action upon. GridView: Contains a grid of View objects, with a specific number of columns; this container is often used with image icons; the user can choose an item to perform some action upon. GalleryView: Contains a horizontally scrolling list of View objects, also often used with image icons; the user can select an item to perform some action upon. These containers are all types of AdapterView controls.An AdapterView control contains a set of child View controls to display data from some data source.An Adapter generates these child View controls from a data source.As this is an important part of all these container controls. Using the ListView The ListView control is commonly used for full-screen menus or lists of items from which a user selects.As such, you might consider using ListActivity as the base class for such screens. Using the ListActivity can simplify these types of screens. First, to handle item events, you now need to provide an implementation in your ListActivity. For instance, the equivalent of onListItemClickListener is to implement the onListItemClick() method within your ListActivity. Second, to assign an Adapter, you need a call to the setListAdapter() method.You do this after the call to the setContentView() method. However, this hints at some of the limitations of using ListActivity. Binding Data to the AdapterView ((ListView)findViewById(R.id.list)).setAdapter(adapter); The call to the setAdapter() method of the AdapterView, a ListView in this case, should come after your call to setContentView(). Handling Selection Events You often use AdapterView controls to present data from which the user should select. All three of the discussed controls—ListView, GridView, and Gallery—enable your application to monitor for click events in the same way.You need to call setOnItemClickListener() on your AdapterView and pass in an implementation of the AdapterView.OnItemClickListener class. Here is an example implementation of this class: Created by: Prof. Adnan Ahmad (9979276001) Page 22 Patel Group of Institutions Subject: Mobile Computing (650003) MCA- Vth Semester av.setOnItemClickListener( new AdapterView.OnItemClickListener() { public void onItemClick( AdapterView<?> parent, View view, int position, long id) { Toast.makeText(Scratch.this, “Clicked _id=”+id, Toast.LENGTH_SHORT).show(); } }); In the preceding example, av is our AdapterView.The implementation of the onItemClick() method is where all the interesting work happens.The parent parameter is the AdapterView where the item was clicked.This is useful if your screen has more than one AdapterView on it. Q23) Explain in brief Array Adapter & Cursor Adapter. Using the ArrayAdapter An ArrayAdapter binds each element of the array to a single View object within the layout resource. Here is an example of creating an ArrayAdapter: private String[] items = { “Item 1”, “Item 2”, “Item 3” }; ArrayAdapter adapt =new ArrayAdapter<String>(this, R.layout.textview, items); In this example,we have a String array called items.This is the array used by the ArrayAdapter as the source data.We also use a layout resource, which is the View that is repeated for each item in the array.This is defined as follows: <TextView xmlns:android= “http://schemas.android.com/apk/res/android” android:layout_width=”fill_parent” android:layout_height=”wrap_content” android:textSize=”20px” /> Created by: Prof. Adnan Ahmad (9979276001) Page 23 Patel Group of Institutions Subject: Mobile Computing (650003) MCA- Vth Semester This layout resource contains only a single TextView.However, you can use a more complex layout with the constructors that also take the resource identifier of a TextView within the layout. Each child View within the AdapterView that uses this Adapter gets one TextView instance with one of the strings from the String array. Using the CursorAdapter A CursorAdapter binds one or more columns of data to one or more View objects within the layout resource provided.This is best shown with an example.The following example demonstrates creating a CursorAdapter by querying the Contacts content provider.The CursorAdapter requires the use of a Cursor. Cursor names = managedQuery(Contacts.Phones.CONTENT_URI, null, null, null, null); startManagingCursor(names); ListAdapter adapter = new SimpleCursorAdapter( this, R.layout.two_text, names, new String[] { Contacts.Phones.NAME, Contacts.Phones.NUMBER }, new int[] { R.id.scratch_text1, R.id.scratch_text2 }); In this example,we present a couple of new concepts. First, you need to know that the Cursor must contain a field named _id. In this case,we know that the Contacts content provider does have this field.This field is used later when you handle the user selecting a particular item. Q24) Explain different types of Dialogs. Q24) How many different dialog types available within the Android SDK? Q24) Write a note on dialog box in android application. Working with Dialogs An Activity can use dialogs to organize information and react to user-driven events. For example, an activity might display a dialog informing the user of a problem or ask the user to confirm an action such as deleting a data record. Using dialogs for simple tasks helps keep the number of application activities manageable. Exploring the Different Types of Dialogs There are a number of different dialog types available within the Android SDK. Each has a special function that most users should be somewhat familiar with.The dialog types available include 1. Dialog: The basic class for all Dialog types. 2. AlertDialog: A Dialog with one, two, or three Button controls. 3. CharacterPickerDialog: A Dialog for choosing an accented character associated with a base character. 4. DatePickerDialog: A Dialog with a DatePicker control. 5. ProgressDialog: A Dialog with a determinate or indeterminate ProgressBar control. 6. TimePickerDialog: A Dialog with a TimePicker control. Tracing the Lifecycle of a Dialog Each Dialog must be defined within the Activity in which it is used.A Dialog may be launched once, or used repeatedly. Understanding how an Activity manages the Dialog lifecycle is important to implementing a Dialog correctly. Let’s look at the key methods that an Activity must use to manage a Dialog: The showDialog() method is used to display a Dialog. The dismissDialog() method is used to stop showing a Dialog.The Dialog is kept around in the Activity’s Dialog pool. If the Dialog is shown again using showDialog(), the cached version is displayed once more. The removeDialog() method is used to remove a Dialog from the Activity objects Dialog pool.The Dialog is no longer kept around for future use. If you call showDialog() again, the Dialog must be re-created. Created by: Prof. Adnan Ahmad (9979276001) Page 24 Patel Group of Institutions Subject: Mobile Computing (650003) MCA- Vth Semester Adding the Dialog to an Activity involves several steps: 1. Define a unique identifier for the Dialog within the Activity. 2. Implement the onCreateDialog() method of the Activity to return a Dialog of the appropriate type, when supplied the unique identifier. 3. Implement the onPrepareDialog() method of the Activity to initialize the Dialog as appropriate. 4. Launch the Dialog using the showDialog() method with the unique identifier. Defining a Dialog A Dialog used by an Activity must be defined in advance. Each Dialog has a special identifier (an integer).When the showDialog() method is called, you pass in this identifier. At this point, the onCreateDialog() method is called and must return a Dialog of the appropriate type. Initializing a Dialog Because a Dialog is often kept around by the Activity in its Dialog pool, it might be important to re-initialize a Dialog each time it is shown, instead of just when it is created the first time. For this purpose, you can override the onPrepareDialog() method of the Activity. Launching a Dialog You can display any Dialog defined within an Activity by calling its showDialog() method and passing it a valid Dialog identifier—one that will be recognized by the onCreateDialog() method. Q25) How many types of menu available in android? Explain creation of any menu with example. Two types of menu available into android Options and Context Menus You need to be aware of two special application menus for use within your Android applications: the options menu and the context menu. Enabling the ContextMenu The ContextMenu is a subtype of Menu that you can configure to display when a long press is performed on a View.As the name implies, the ContextMenu provides for contextual menus to display to the user for performing additional actions on selected items. ContextMenu objects are slightly more complex than OptionsMenu objects.You need to implement the onCreateContextMenu() method of your Activity for one to display. However, before that is called, you must call the registerForContextMenu() method and pass in the View for which you want to have a context menu. Here we have an example of a Chronometer timer, which responds to a long click with a context menu: registerForContextMenu(timer); The following is an example of a context menu for the Chronometer control, as previously used: public void onCreateContextMenu( ContextMenu menu, View v, ContextMenuInfo menuInfo) { super.onCreateContextMenu(menu, v, menuInfo); if (v.getId() == R.id.Chronometer01) { getMenuInflater().inflate(R.menu.timer_context, menu); menu.setHeaderIcon(android.R.drawable.ic_media_play) .setHeaderTitle(“Timer controls”); } } You can also include menu resources in your project files. Like animation resources, menu resources are not tied to a specific control but can be reused in any menu control.Each menu resource (which is a set of individual menu Created by: Prof. Adnan Ahmad (9979276001) Page 25 Patel Group of Institutions Subject: Mobile Computing (650003) MCA- Vth Semester items) is stored as a specially formatted XML files in the /res/menu directory and are compiled into the application package at build time. Here’s an example of a simple menu resource file /res/menu/speed.xml that defines a short menu with four items in a specific order: <menu xmlns:android=”http://schemas.android.com/apk/res/android”> <item android:id=”@+id/start” android:title=”Start!” android:orderInCategory=”1”></item> <item android:id=”@+id/stop” android:title=”Stop!” android:orderInCategory=”4”></item> <item android:id=”@+id/accel” android:title=”Reset” android:orderInCategory=”2”></item> </menu> To access the preceding menu resource called /res/menu/speed.xml, simply override the method onCreateOptionsMenu() in your application: public boolean onCreateOptionsMenu(Menu menu) { getMenuInflater().inflate(R.menu.speed, menu); return true; } Now we need to handle the ContextMenu clicks by implementing the onContextItemSelected() method in our Activity. Here’s an example: public boolean onContextItemSelected(MenuItem item) { super.onContextItemSelected(item); boolean result = false; Chronometer timer = (Chronometer)findViewById(R.id.Chronometer01); switch (item.getItemId()){ case R.id.stop_timer: timer.stop(); result = true; break; case R.id.start_timer: timer.start(); result = true; break; case R.id.reset_timer: timer.setBase(SystemClock.elapsedRealtime()); result = true; break; } return result; } Enabling the Options Menu: The Android SDK provides a method for users to bring up a menu by pressing the menu key from within the application .You can use options menus within your application to bring up help, to navigate, to provide additional controls, or to configure options.The OptionsMenu control can contain icons, submenus, and keyboard shortcuts. For an options menu to show when a user presses the Menu button on their device, you need to override the implementation of onCreateOptionsMenu() in your Activity. Here is a sample implementation that gives the user three menu items to choose from: Created by: Prof. Adnan Ahmad (9979276001) Page 26 Patel Group of Institutions Subject: Mobile Computing (650003) MCA- Vth Semester public boolean onCreateOptionsMenu( android.view.Menu menu) { super.onCreateOptionsMenu(menu); menu.add(“Forms”) .setIcon(android.R.drawable.ic_menu_edit) .setIntent(new Intent(this, FormsActivity.class)); menu.add(“Indicators”) .setIntent(new Intent(this, IndicatorsActivity.class)) .setIcon(android.R.drawable.ic_menu_info_details); menu.add(“Containers”) .setIcon(android.R.drawable.ic_menu_view) .setIntent(new Intent(this, ContainersActivity.class)); return true; } the following is code for programmatically adding a SubMenu control to the previous Menu: SubMenu style_choice = menu.addSubMenu(“Style”) .setIcon(android.R.drawable.ic_menu_preferences); style_choice.add(style_group, light_id, 1, “Light”) .setChecked(isLight); style_choice.add(style_group, dark_id, 2, “Dark”) .setChecked(!isLight); style_choice.setGroupCheckable(style_group, true, true); To handle the event when a menu option item is selected,we also implement the onOptionsItemSelected() method, as shown here: public boolean onOptionsItemSelected(MenuItem item) { if (item.getItemId() == light_id) { item.setChecked(true); isLight = true; return true; } else if (item.getItemId() == dark_id) { item.setChecked(true); isLight = false; return true; } return super.onOptionsItemSelected(item); } Q26) Write Short notes style and theme. Working with Styles Android user interface designers can group layout element attributes together in styles. Layout controls are all derived from the View base class, which has many useful attributes. Individual controls, such as Checkbox, Button, and TextView, have specialized attributes associated with their behavior. Styles are tagged with the <style> tag and should be stored in the /res/values/ directory. Style resources are defined in XML and compiled into the application binary at build time. Here’s an example of a simple style resource file /res/values/styles.xml containing two styles: one for mandatory form fields, and one for optional form fields on TextView and EditText objects: <?xml version=”1.0” encoding=”utf-8”?> <resources> <style name=”mandatory_text_field_style”> <item name=”android:textColor”>#000000</item> Created by: Prof. Adnan Ahmad (9979276001) Page 27 Patel Group of Institutions Subject: Mobile Computing (650003) MCA- Vth Semester <item name=”android:textSize”>14pt</item> <item name=”android:textStyle”>bold</item> </style> <style name=”optional_text_field_style”> <item name=”android:textColor”>#0F0F0F</item> <item name=”android:textSize”>12pt</item> <item name=”android:textStyle”>italic</item> </style> </resources> Working with Themes Themes are much like styles, but instead of being applied to one layout element at a time, they are applied to all elements of a given activity (which, generally speaking, means one screen). Themes are defined in exactly the same way as styles.Themes use the <style> tag and should be stored in the /res/values directory.The only difference is that instead of applying that named style to a layout element, you define it as the theme attribute of an activity in the AndroidManifest.xml file. For instance, consider the following style: <style name=”right”> <item name=”android:gravity”>right</item></style> You can apply this as a theme to the whole screen, which causes any view displayed within that Activity to have its gravity attribute to be right-justified.Applying this theme is as simple as making the method call to the setTheme() method from within the Activity, as shown here: setTheme(R.style.right); Q27) What is WebView? How can we load content into WebView? How can we handle WebView events? Other GUI toolkits let you use HTML for presenting information, from limited HTML renderers (e.g., Java/Swing) to embedding Internet Explorer into .NET applications. Android is much the same, in that you can embed the built-in Web browser as a widget in your own activities, for displaying HTML or full-fledged browsing. The Android browser is based on WebKit, the same engine that powers Apple’s Safari Web browser. The Android browser is sufficiently complex that it gets its own Java package (android.webkit), though using the WebView widget itself can be simple or powerful, based upon your requirements. For simple stuff, WebView is not significantly different than any other widget in Android—pop it into a layout, tell it what URL to navigate to via Java code, and you’re done. Because this application needs access to the Internet, you need to add the appropriate permissions to the Android Created by: Prof. Adnan Ahmad (9979276001) Page 28 Patel Group of Institutions Subject: Mobile Computing (650003) MCA- Vth Semester manifest file. Open the AndroidManifest.xml file and add the following as a child of the <manifest> element: Q28) What is shared preferences? Explain methods for create, search, read, add, update and delete shared preference? Android provides a simple preferences system for storing primitive application data at the Activity level and preferences shared across all of an application’s activities.You cannot share preferences outside of the package. Preferences are stored as groups of key/value pairs.The following data types are supported as preference settings: Boolean values Float values Integer values Long values String values Preference functionality can be found in the SharedPreferences interface of the android.content package.To add preferences support to your application, you must take the following steps: 1. Retrieve an instance of a SharedPreferences object. 2. Create a SharedPreferences.Editor to modify preference content. 3. Make changes to the preferences using the Editor. 4. Commit your changes. Creating Private and Shared Preferences: The following code retrieves the activity’s private preferences: import android.content.SharedPreferences; ... SharedPreferences settingsActivity = getPreferences(MODE_PRIVATE); Creating shared preferences is similar.The only two differences are that we must name our preference set and use a different call to get the preference instance: import android.content.SharedPreferences; ... SharedPreferences settings = getSharedPreferences(“MyCustomSharedPreferences”, 0); Searching and Reading Preferences Reading preferences is straightforward. Simply retrieve the SharedPreferences instance you want to read.You can check for a preference by name, retrieve strongly typed preferences, and register to listen for changes to the preferences. Some following helpful methods in the SharedPreferences interface. The following Important android.content.SharedPreferences Methods Method Purpose SharedPreferences.contains() Sees whether a specific preference exists by name SharedPreferences.edit() Retrieves the editor to change these preferences SharedPreferences.getAll() Retrieves a map of all preference key/value pairs SharedPreferences.getBoolean() Retrieves a specific Boolean-type preference by name SharedPreferences.getFloat() Retrieves a specific Float-type preference by name SharedPreferences.getInt() Retrieves a specific Integer-type preference by name SharedPreferences.getLong() Retrieves a specific Long-type preference by name SharedPreferences.getString() Retrieves a specific String-type preference by name Adding, Updating, and Deleting Preferences To change preferences, you need to open the preference Editor, make your changes, and commit them. The following describes some helpful methods in the SharedPreferences.Editor interface. The following Important android.content.SharedPreferences Methods Created by: Prof. Adnan Ahmad (9979276001) Page 29 Patel Group of Institutions MCA- Vth Semester Subject: Mobile Computing (650003) Method SharedPreferences.Editor.clear() Purpose Removes all preferences. This operation happens first, regardless of when it is called within an editing session;then all other changes are made and committed. SharedPreferences.Editor.remove() SharedPreferences.Editor.putBoolean() SharedPreferences.Editor.putFloat() SharedPreferences.Editor.putInt() SharedPreferences.Editor.putLong() SharedPreferences.Editor.putString() SharedPreferences.Editor.commit() Removes a specific preference by name. This operation happens first, regardless of when it is called within an editing session; then all other changes are made and committed. Sets a specific Boolean-type preference by name. Sets a specific Float-type preference by name. Sets a specific Integer-type preference by name. Sets a specific Long-type preference by name. Sets a specific String-type preference by name. Commits all changes from this editing session. Finding Preferences Data on the Android File System Internally, application preferences are stored as XML files.You can access the preferences file using DDMS using the File Explorer.You find these files on the Android file system in the following directory: /data/data/<package name>/shared_prefs/<preferences filename>.xml Q29) What is SQLite Databse? Explain methods for creating, updating, anddeleting and querying database records. Q29) Explain the use of ContentValues to insert the record and Which four arguments are taken by update ()? SQLite Databases: For occasions when your application requires a more robust data storage mechanism, the Android file system includes support for application-specific relational databases using SQLite. SQLite databases are lightweight and file-based, making them ideally suited for embedded devices. These databases and the data within them are private to the application.To share application data with other applications; you must expose the data you want to share by making your application a content provider. The Android SDK includes a number of useful SQLite database management classes. Many of these classes are found in the android.database.sqlite package. Here you can find utility classes for managing database creation and versioning, database management, and query builder helper classes to help you format proper SQL statements and queries. Finding the Application’s Database File on the Device File System: Android applications store their databases (SQLite or otherwise) in a special application directory: /data/data/<application package name>/databases/<databasename> So, in this case, the path to the database would be /data/data/com.androidbook.SimpleDatabase/databases/my_sqlite_database.db 1. Creating a SQLite Database Instance Using the Application Context: The simplest way to create a new SQLiteDatabase instance for your application is to use the openOrCreateDatabase() method of your application Context, like this: import android.database.sqlite.SQLiteDatabase; ... SQLiteDatabase mDatabase = openOrCreateDatabase(“my_sqlite_database.db”, SQLiteDatabase.CREATE_IF_NECESSARY,null); OR SQLiteDatabase mDatabase=openOrCreateDatabase("Mydb",MODE_PRIVATE,null); 2. Creating Tables and Other SQLite Schema Objects CREATE TABLE tbl_authors ( id INTEGER PRIMARY KEY AUTOINCREMENT, firstname TEXT, lastname TEXT); Created by: Prof. Adnan Ahmad (9979276001) Page 30 Patel Group of Institutions Subject: Mobile Computing (650003) MCA- Vth Semester You can encapsulate this CREATE TABLE SQL statement in a static final String variable (called CREATE_AUTHOR_TABLE) and then execute it on your database using the execSQL() method: mDatabase.execSQL(CREATE_AUTHOR_TABLE); OR mDatabase.execSQL("create table if not exists tbl_authors (id integer ,firstname varchar,lastname varchar);"); execSQL() method: The execSQL() method works for nonqueries.You can use it to execute any valid SQLite SQL statement. For example, you can use it to create, update, and delete tables, views, triggers, and other common SQL objects. 3. Creating, Updating, and Deleting Database Records: Now that we have a database set up,we need to create some data.The SQLiteDatabase class includes three convenience methods to do that.They are, as you might expect, insert(), update(), and delete(). a) Inserting Records: We use the insert() method to add new data to our tables.We use the ContentValues object to pair the column names to the column values for the record we want to insert. For example, here we insert a record into tbl_authors for J.K. Rowling: import android.content.ContentValues; ... ContentValues values = new ContentValues(); values.put(“firstname”, “J.K.”); values.put(“lastname”, “Rowling”); long newAuthorID = mDatabase.insert(“tbl_authors”, null, values); The insert() method returns the id of the newly created record.We use this author id to create book records for this author. OR mDatabase.execSQL("insert into Mytable values('J.K.','Rowling');"); b) Updating Records: You can modify records in the database using the update() method.The update() method takes four arguments: The table to update records A ContentValues object with the modified fields to update An optional WHERE clause, in which ? identifies a WHERE clause argument An array of WHERE clause arguments, each of which is substituted in place of the ?’s from the second parameter Passing null to the WHERE clause modifies all records within the table, which can be useful for making sweeping changes to your database. public void updateBookTitle(Integer bookId, String newtitle) { ContentValues values = new ContentValues(); values.put(“title”, newtitle); mDatabase.update(“tbl_books”, values, “id=?”, new String[] { bookId.toString() }); } c) Deleting Records: You can remove records from the database using the remove() method.The remove() method takes three arguments: The table to delete the record from An optional WHERE clause, in which ? identifies a WHERE clause argument An array of WHERE clause arguments, each of which is substituted in place of the ?’s from the second parameter Created by: Prof. Adnan Ahmad (9979276001) Page 31 Patel Group of Institutions Subject: Mobile Computing (650003) MCA- Vth Semester Passing null to the WHERE clause deletes all records within the table. For example, this function call deletes all records within the table called tbl_authors: mDatabase.delete(“tbl_authors”, null, null); Most of the time, though,we want to delete individual records by their unique identifiers. The following function takes a parameter bookId and deletes the record corresponding to that unique id (primary key) within the table called tbl_books: public void deleteBook(Integer bookId) { mDatabase.delete(“tbl_books”, “id=?”, new String[] { bookId.toString() }); } 4. Querying SQLite Databases: Databases are great for storing data in any number of ways, but retrieving the data you want is what makes databases powerful.This is partly a matter of designing an appropriate database schema, and partly achieved by crafting SQL queries, most of which are SELECT statements. Working with Cursors: When results are returned from a SQL query, you often access them using a Cursor found in the android.database.Cursor class. Cursor objects are rather like file pointers; they allow random access to query results. // SIMPLE QUERY: select * from tbl_books Cursor c = mDatabase.query(“tbl_books”,null,null,null,null,null,null); OR Cursor c=db.rawQuery("select * from tbl_books",null); // Do something quick with the Cursor here... c.close(); query() method: Your first stop for database queries should be the query() methods available in the SQLiteDatabase class.This method queries the database and returns any results as in a Cursor object. The query() method we mainly use takes the following parameters: [String]:The name of the table to compile the query against [String Array]: List of specific column names to return (use null for all) [String] The WHERE clause: Use null for all; might include selection args as ?’s [String Array]:Any selection argument values to substitute in for the ?’s in the earlier parameter [String] GROUP BY clause: null for no grouping [String] HAVING clause: null unless GROUP BY clause requires one [String] ORDER BY clause: If null, default ordering used [String] LIMIT clause: If null, no limit Previously in the chapter,we called the query() method with only one parameter set to the table name. Cursor c = mDatabase.query(“tbl_books”,null,null,null,null,null,null); This is equivalent to the SQL query SELECT * FROM tbl_books; Add a WHERE clause to your query, so you can retrieve one record at a time: Cursor c = mDatabase.query(“tbl_books”, null, “id=?”, new String[]{“9”}, null, null, null); This is equivalent to the SQL query SELECT * tbl_books WHERE id=9; Created by: Prof. Adnan Ahmad (9979276001) Page 32 Patel Group of Institutions MCA- Vth Semester Subject: Mobile Computing (650003) Q30) What is limitation of SQLite? SQLite Limitations: SQLite is powerful, but it has several important limitations compared to traditional SQL Server implementations, such as the following: SQLite is not a substitute for a high-powered, server-driven database. Being file-based, the database is meant to be accessed in a serial, not a concurrent, manner.Think “single user”—the Android application. It has some concurrency features, but they are limited. Access control is maintained by file permissions, not database user permissions. Referential integrity is not maintained. For example, FOREIGN KEY constraints are parsed (for example, in CREATE TABLE) but not enforced automatically. However, using TRIGGER functions can enforce them. ALTER TABLE support is limited.You can use only RENAME TABLE and ADD COLUMN.You may not drop or alter columns or perform any other such operations. This can make database upgrades a bit tricky. TRIGGER support is limited.You cannot use FOR EACH STATEMENT or INSTEAD OF.You cannot create recursive triggers. You cannot nest TRANSACTION operations. VIEWs are read-only. You cannot use RIGHT OUTER JOINs or FULL OUTER JOINs. SQLite does not support STORED PROCEDUREs or auditing. The built-in FUNCTIONs of the SQL language are limited. Q31) What is Content Provider? List useful built-in content providers with its purpose and explain any one of them in details. Content Provider: Applications can access data within other applications on the Android system through content provider interfaces and expose internal application data to other applications by becoming a content provider. To share application data with other applications; you must expose the data you want to share by making your application a content provider. Useful Built-In Content Providers Provider MediaStore CallLog Browser ContactsContract Settings UserDictionary Purpose Audio-visual data on the phone and external storage Sent and received calls Browser history and bookmarks Phone contact database or phonebook System-wide device settings and preferences A dictionary of user-defined words for use with predictive text input ContactsContract Content Provider: The Contacts database is one of the most commonly used applications on the mobile phone. People always want phone numbers handy for calling friends, family, coworkers, and clients.Additionally, most phones show the identity of the caller based on the contacts application, including nicknames, photos, or icons. Android provides a built-in Contact application, and the contact data is exposed to other Android applications using the content provider interface. Accessing Private Contact Data: Your application needs special permission to access the private user information provided by the Contacts content provider.You must declare a uses-permission tag using the permission READ_CONTACTS to read this information. The code to start reading contact data from the Contacts application should look familiar. Cursor oneContact = managedQuery( People.CONTENT_URI, null, null, null, “name desc LIMIT 1”); Log.d(debugTag, “Count: “ + oneContact.getCount()); Created by: Prof. Adnan Ahmad (9979276001) Page 33 Patel Group of Institutions Subject: Mobile Computing (650003) MCA- Vth Semester Now that we have the column index values for the contact’s name, primary email address, and primary phone number,we need to build the Uri objects associated with those pieces of information and query for the primary email and primary phone number. Uri emailUri = ContentUris.withAppendedId( Contacts.ContactMethods.CONTENT_URI, emailID); Uri phoneUri = ContentUris.withAppendedId( Contacts.Phones.CONTENT_URI, phoneID); Cursor primaryEmail = managedQuery(emailUri, new String[] { Contacts.ContactMethods.DATA}, null, null, null); Cursor primaryNumber = managedQuery(phoneUri,new String[] {Contacts.Phones.NUMBER},null, null, null); Querying for a Specific Contact: If that seemed like quite a lot of coding to get a phone number, you’re not alone. For getting a quick piece of data, there is a faster way.The following block of code demonstrates how we can get the primary number and name for one contact. String[] requestedColumns = {Contacts.Phones.NAME,Contacts.Phones.NUMBER,}; Cursor contacts = managedQuery(Contacts.Phones.CONTENT_URI,requestedColumns, Contacts.Phones.ISPRIMARY + “<>0”,null, “name desc limit 1”); Log.d(debugTag, “Contacts count: “+ contacts.getCount()); Modifying Content Providers Data: Content providers are not only static sources of data.They can also be used to add, update, and delete data, if the content provider application has implemented this functionality. Your application must have the appropriate permissions (that is, WRITE_CONTACTS as opposed to READ_CONTACTS) to perform some of these actions. Adding Records: Using the Contacts content provider,we can, for example, add a new record to the contacts database programmatically. ContentValues values = new ContentValues(); values.put(Contacts.People.NAME, “Sample User”); Uri uri = getContentResolver().insert( Contacts.People.CONTENT_URI, values); Uri phoneUri = Uri.withAppendedPath(uri, Contacts.People.Phones.CONTENT_DIRECTORY); values.clear(); values.put(Contacts.Phones.NUMBER, “2125551212”); values.put(Contacts.Phones.TYPE, Contacts.Phones.TYPE_WORK); getContentResolver().insert(phoneUri, values); values.clear(); values.put(Contacts.Phones.NUMBER, “3135551212”); values.put(Contacts.Phones.TYPE, Contacts.Phones.TYPE_MOBILE); getContentResolver().insert(phoneUri, values); Updating Records Inserting data isn’t the only change you can make.You can update one or more rows, as well.The following block of code shows how to update data within a content provider. In this case,we update a note field for a specific contact, using its unique identifier. ContentValues values = new ContentValues(); values.put(People.NOTES, “This is my boss”); Uri updateUri = ContentUris.withAppendedId(People.CONTENT_URI, rowId); int rows = getContentResolver().update(updateUri, values, null, null); Log.d(debugTag, “Rows updated: “ + rows); Created by: Prof. Adnan Ahmad (9979276001) Page 34 Patel Group of Institutions Subject: Mobile Computing (650003) MCA- Vth Semester Deleting All Records The following code deletes all rows at the given URI, although you should execute operations like this with extreme care: int rows = getContentResolver().delete(People.CONTENT_URI, null, null); Log.d(debugTag, “Rows: “+ rows); The delete() method deletes all rows at a given URI filtered by the selection parameters, which, in this case, includes all rows at the People.CONTENT_URI location; in other words, all contact entries. Q32) List permission required for following task 1. Send SMS 2. Receive SMS 3. To access phone state Information 4. Add contact details 5. Write file to SD Card 6. To access online URL 7. To dial number 8. Read contacts 9. To use Map 1. Send SMS=android.permission.SEND_SMS 2. Receive SMS=android.permission.RECEIVE_SMS 3. To access phone state Information=android.permission.READ_PHONE_STATE 4. Add contact details=android.permission.WRITE_CONTACTS 5. Write file to SD Card=android.permission.WRITE_EXTERNAL_STORAGE 6. To access online URL=android.permission.ACCESS_NETWORK_STATE 7. To dial number=android.permission.CALL_PHONE 8. Read contacts=android.permission.READ_CONTACTS 9. To use map=android.permission.INTERNET Q33) Explain the following methods. (a)PhoneNumberUtils.formatNumber () (b)SmsManager.getDefault () (c) Bundle data = intent.getExtras(); (d) SmsMessage.createFromPdu((byte[])pdu); (a) Applications that deal with telephony, or even just contacts, frequently have to deal with the input, verification, and usage of phone numbers.The Android SDK includes a set of helpful utility functions that simplify handling of phone number strings.Applications can have phone numbers formatted based on the current locale setting. For example, the following code uses the formatNumber() method: String formattedNumber = PhoneNumberUtils.formatNumber(“9995551212”); Log.i(“telephony”, formattedNumber); The resulting output to the log would be the string 999-555-1212 in my locale. (b) To send an SMS, an application first needs to get an instance of the SmsManager. Unlike other system services, this is achieved by calling the static method getDefault() of SmsManager: final SmsManager sms = SmsManager.getDefault(); Now that the application has the SmsManager, sending SMS is as simple as a single call: sms.sendTextMessage(“9995551212”, null, “Hello!”, null, null); Created by: Prof. Adnan Ahmad (9979276001) Page 35 Patel Group of Institutions Subject: Mobile Computing (650003) MCA- Vth Semester (c) This block of code is placed within the onCreate() method of the Activity. First, the message Bundle is retrieved. In it, an array of Objects holds several byte arrays that contain PDU data. For Example: Bundle data = intent.getExtras(); if (data != null) { Object pdus[] =(Object[]) data.get(“pdus”);} (d) The PDU data format that is customarily used by wireless messaging protocols.Luckily, the Android SDK can decode these with a call to the static SmsMessage.createFromPdu() utility method. From here,we can retrieve the body of the SMS message by calling getDisplayMessageBody(). For Example: for (Object pdu : pdus) { SmsMessage part = SmsMessage.createFromPdu((byte[])pdu); message += part.getDisplayMessageBody(); } Q34) What is notification? How it is differ from Toast? Q34) What is different between Toast and Alert Dialog? Notification: Applications often need to communicate with the user even when the application isn’t actively running. Applications can alert users with text notifications, vibration, blinking lights, and even audio. The standard location for displaying notifications and indicators on an Android device is the status bar that runs along the top of the screen.Typically, the status bar shows information such as the current date and time. It also displays notifications (like incoming SMS messages) as they arrive—in short form along the bar and in full if the user pulls down the status bar to see the notification list. A simple notification has a number of important components: An icon (appears on status bar and full notification) Ticker text (appears on status bar) Notification title text (appears in full notification) Notification body text (appears in full notification) An intent (launches if the user clicks on the full notification) Using the NotificationManager Service: All notifications are created with the help of the NotificationManager.The NotificationManager (within the android.app package) is a system service that must be requested.The following code demonstrates how to obtain a valid NotificationManager object using the getSystemService() method: NotificationManager notifier = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE); Creating a Simple Text Notification with an Icon: You can set the icon and ticker text, both of which display on the status bar, through the constructor for the Notification object, as follows: Notification notify = new Notification(R.drawable.android_32, "Hello!", System.currentTimeMillis()); Additionally, you can set notification information through public member variable assignment, like this: notify.icon = R.drawable.android_32; notify.tickerText = "Hello!"; notify.when = System.currentTimeMillis(); Raising Toasts: A Toast is a transient message, meaning that it displays and disappears on its own without user interaction. Toast is transient, you have no way of knowing if the user even notices it. You get no acknowledgment from them, nor does the message stick around for a long time to pester the user. Hence, the Toast is mostly for advisory messages, such as indicating a long-running background task is completed, the battery has dropped to a low-but-not-too-low level, etc. Toast.makeText(this,”Hello Toast”,Toast.LENGTH_LONG).show(); Created by: Prof. Adnan Ahmad (9979276001) Page 36 Patel Group of Institutions Subject: Mobile Computing (650003) MCA- Vth Semester Alert Dialog: If you would prefer something in the more classic dialog-box style, what you want is an AlertDialog. As with any other modal dialog box, an AlertDialog pops up, grabs the focus, and stays there until closed by the user. New AlertDialog.Builder(this).setTitle(“Message Demo”).setMessage(“Hello Alert!!”) .setNeutralButton(“close!”,new DialogInterface.OnClickListener() { Public void onClick(DialogInterface dialog,int which) { } }).show(); Q35) Which control used to retrieve data from user? Explain any two controls with example. Retrieving Data from Users The Android SDK provides a number of controls for retrieving data from users. One of the most common types of data that applications often need to collect from users is text. Many controls to handle this type of job are EditText controls,Spinner controls,Check Boxes, RadioButtons and RadioGroups. A. Retrieving Text Input Using EditText Controls: The Android SDK provides a convenient control called EditText to handle text inputfrom a user.The EditText class is derived from TextView. In fact, most of its functionality is contained within TextView but enabled when created as an EditText.The EditText object has a number of useful features enabled by default, many of which are shown in First, though, let’s see how to define an EditText control in an XML layout file: <EditText android:id=”@+id/EditText01” android:layout_height=”wrap_content” android:hint=”type here” android:lines=”4” android:layout_width=”fill_parent” /> The EditText object is essentially an editable TextView. It accepts multiline entry and word wrapping.This means that you can read text from it in the same way as you did with TextView: by using the getText() method. You can also set initial text to draw in the text entry area using the setText() method. Final EditText ed=(EditText)findViewById(R.id.edittext1); String msg=ed.getText().toString(); B. Spinner : Composite control that displays a TextView and an associated ListView that lets you select an item from a list to display in the textbox. It’s made from a Text View displaying the current selection, combined with a button that displays a selection dialog when pressed. <Spinner android:id=”@+id/Spinner01” android:layout_width=”wrap_content” android:layout_height=”wrap_content” android:entries=”@array/colors” android:prompt=”@string/spin_prompt” /> we could have called the getSelectedItem() or getSelectedItemId() methods to deal with other forms of selection. Example: Created by: Prof. Adnan Ahmad (9979276001) Page 37 Patel Group of Institutions Subject: Mobile Computing (650003) MCA- Vth Semester Q36) Explain: TextView, Spinner, and ProgressBar with example. (Purpose, syntax, xml elements related java methods, event example etc). Q36) What is uses of following widget and list its properties and event. ( rating bar, seek bar, toggle button, CheckBox,image view, Chronometer) a) CheckBox: A CheckBox is a button with two states—checked or unchecked.You often uses CheckBox controls to turn a feature on or off or to pick multiple items from a list. <CheckBox android:id=”@+id/checkbox” android:layout_width=”wrap_content” android:layout_height=”wrap_content” android:text=”Check me?” /> Example: b) ToggleButton: A ToggleButton is similar to a CheckBox, but you use it to visually show the state.The default behavior of a toggle is like that of a power on/off button. Like the CheckBox, it has a state (checked or not). Also like the check box, the act of changing what displays on the button is handled for us. Unlike the CheckBox, it does not show text next to it. Instead, it has two text fields.The first attribute is textOn, which is the text that displays on the button when its checked Created by: Prof. Adnan Ahmad (9979276001) Page 38 Patel Group of Institutions Subject: Mobile Computing (650003) MCA- Vth Semester state is on.The second attribute is textOff, which is the text that displays on the button when its checked state is off.The default text for these is “ON” and “OFF,” respectively. <ToggleButton android:id=”@+id/toggle_button” android:layout_width=”wrap_content” android:layout_height=”wrap_content” android:text=”Toggle” android:textOff=”Disabled” android:textOn=”Enabled” /> c) TextView : (Display data to Users) One of the most basic user interface elements, or controls, in the Android SDK is the TextView control.You use it, quite simply, to draw text on the screen.You primarily use it to display fixed text strings or labels. A standard read only text label. It supports multiline display, string formatting, and automatic word wrapping. <TextView android:id=”@+id/TextView01” android:layout_width=”wrap_content” android:layout_height=”wrap_content” android:text=”Some sample text here” /> Creating Contextual Links in Text: none: Disables all linking. web: Enables linking of URLs to web pages. email: Enables linking of email addresses to the mail client with the recipient filled. phone: Enables linking of phone numbers to the dialer application with the phone number filled out, ready to be dialed. map: Enables linking of street addresses to the map application to show the location. nall: Enables all types of linking. <TextView android:id=”@+id/TextView02” android:layout_width=”wrap_content” android:layout_height=”wrap_content” android:text=”@string/autolink_test” android:autoLink=”web|email” /> You can change the text displayed programmatically by calling the setText() method on the TextView object. Retrieving the text is done with the getText() method. d) ProgressBar: Applications commonly perform actions that can take a while.A good practice during this time is to show the user some sort of progress indicator that informs the user that the application is off “doing something.”Applications can also show how far a user is through some operation, such as a playing a song or watching a video.The Android SDK provides several types of progress bars. The standard progress bar is a circular indicator that only animates. It does not show how complete an action is. It can, however, show that something is taking place.This is useful when an action is indeterminate in length.The following shows the layout definition for a horizontal progress indicator: <ProgressBar android:id=”@+id/progress_bar” style=”?android:attr/progressBarStyleHorizontal” android:layout_width=”fill_parent” android:layout_height=”wrap_content” android:max=”100” /> Created by: Prof. Adnan Ahmad (9979276001) Page 39 Patel Group of Institutions Subject: Mobile Computing (650003) MCA- Vth Semester We can set the indicator progress status programmatically as follows: mProgress = (ProgressBar) findViewById(R.id.progress_bar); mProgress.setProgress(75); requestWindowFeature(Window.FEATURE_INDETERMINATE_PROGRESS); requestWindowFeature(Window.FEATURE_PROGRESS); setContentView(R.layout.indicators); setProgressBarIndeterminateVisibility(true); setProgressBarVisibility(true); setProgress(5000); To use the indeterminate indicator on your Activity objects title bar, you need to request the feature Window.FEATURE_INDETERMINATE_PROGRESS, as previously shown.This shows a small circular indicator in the right side of the title bar. For a horizontal progress bar style that shows behind the title, you need to enable the Window.FEATURE_PROGRESS. e) SeekBar: You have seen how to display progress to the user.What if, however, you want to give the user some ability to move the indicator, for example, to set the current cursor position in a playing media file or to tweak a volume setting? You accomplish this by using the SeekBar control provided by the Android SDK. It’s like the regular horizontal progress bar, but includes a thumb, or selector, that can be dragged by the user.A default thumb selector is provided, but you can use any drawable item as a thumb. Here we have an example of an XML layout resource definition for a simple SeekBar: <SeekBar android:id=”@+id/seekbar1” android:layout_height=”wrap_content” android:layout_width=”240px” android:max=”500” /> you can provide an implementation of the onProgressChanged() method, as shown here: SeekBar seek = (SeekBar) findViewById(R.id.seekbar1); seek.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() { public void onProgressChanged( SeekBar seekBar, int progress,boolean fromTouch) { ((TextView)findViewById(R.id.seek_text)) .setText(“Value: “+progress); seekBar.setSecondaryProgress((progress+seekBar.getMax())/2); } }); f) RatingBar: Although the SeekBar is useful for allowing a user to set a value, such as the volume, the RatingBar has a more specific purpose: showing ratings or getting a rating from a user. By default, this progress bar uses the star paradigm with five stars by default.A user can drag across this horizontal to set a rating.A program can set the value, as well. However, the secondary indicator cannot be used because it is used internally by this particular control. Here’s an example of an XML layout resource definition for a RatingBar with four stars: <RatingBar android:id=”@+id/ratebar1” android:layout_width=”wrap_content” android:layout_height=”wrap_content” android:numStars=”4” android:stepSize=”0.25” /> You can do this by implementing the onRatingChanged() method of the RatingBar.OnRatingBarChangeListener class. RatingBar rate = (RatingBar) findViewById(R.id.ratebar1); Created by: Prof. Adnan Ahmad (9979276001) Page 40 Patel Group of Institutions Subject: Mobile Computing (650003) MCA- Vth Semester rate.setOnRatingBarChangeListener(new RatingBar.OnRatingBarChangeListener() { public void onRatingChanged(RatingBar ratingBar,float rating, boolean fromTouch) { ((TextView)findViewById(R.id.rating_text)).setText(“Rating: “+ rating); }}); g) ImageView: ImageView control is used to display image. It fetch image from drawable resource folder. It has “src” property to set the image path from drawable folder. <ImageView android:id="@+id/imageView1" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignParentLeft="true" android:layout_alignParentTop="true" android:layout_marginLeft="66dp" android:layout_marginTop="79dp" android:src="@drawable/ic_launcher" /> h) Chronometer: Sometimes you want to show time passing instead of incremental progress. In this case, you can use the Chronometer control as a timer. This might be useful if it’s the user who is taking time doing some task or in a game where some action needs to be timed.The Chronometer control can be formatted with text, as shown in this XML layout resource definition: <Chronometer android:id=”@+id/Chronometer01” android:layout_width=”wrap_content” android:layout_height=”wrap_content” android:format=”Timer: %s” /> You can use the Chronometer object’s format attribute to put text around the time that displays. A Chronometer won’t show the passage of time until its start() method is called.To stop it, simply call its stop() method. Finally, you can change the time from which the timer is counting.That is, you can set it to count from a particular time in the past instead of from the time it’s started.You call the setBase() method to do this. we start the timer counting up from there. final Chronometer timer =(Chronometer)findViewById(R.id.Chronometer01); long base = timer.getBase(); Log.d(ViewsMenu.debugTag, “base = “+ base); timer.setBase(0); timer.start(); You can listen for changes to the Chronometer by implementing the Chronometer.OnChronometerTickListener interface. Note: for Spinner control refer question no. 35. Q37) What is Gradient? How many types of gradient available?Explain different gradient. Gradients: You can create a gradient of colors using one of the gradient subclasses.The different gradient classes including LinearGradient, RadialGradient, and SweepGradient, are available under the superclass android.graphics.Shader. All gradients need at least two colors—a start color and an end color—but might contain any number of colors in an array.The different types of gradients are differentiated by the direction in which the gradient “flows.” Gradients can be set to mirror and repeat as necessary. You can set the Paint gradient using the setShader() method. Created by: Prof. Adnan Ahmad (9979276001) Page 41 Patel Group of Institutions Subject: Mobile Computing (650003) MCA- Vth Semester i. Linear Gradients: A linear gradient is one that changes colors along a single straight line. import android.graphics.Canvas; import android.graphics.Color; import android.graphics.LinearGradient; import android.graphics.Paint; import android.graphics.Shader; Paint circlePaint = new Paint(Paint.ANTI_ALIAS_FLAG); LinearGradient linGrad = new LinearGradient(0, 0, 25, 25, Color.RED, Color.BLACK, Shader.TileMode.MIRROR); circlePaint.setShader(linGrad); canvas.drawCircle(100, 100, 100, circlePaint); ii. Radial Gradients: A radial gradient is one that changes colors starting at a single point and radiating outward in a circle. import android.graphics.Canvas; import android.graphics.Color; import android.graphics.RadialGradient; import android.graphics.Paint; import android.graphics.Shader; Paint circlePaint = new Paint(Paint.ANTI_ALIAS_FLAG); RadialGradient radGrad = new RadialGradient(250, 175, 50, Color.GREEN, Color.BLACK, Shader.TileMode.MIRROR); circlePaint.setShader(radGrad); canvas.drawCircle(250, 175, 50, circlePaint); iii. Sweep Gradients: A sweep gradient is one that changes colors using slices of a pie.This type of gradient is often used for a color chooser. import android.graphics.Canvas; import android.graphics.Color; import android.graphics.SweepGradient; import android.graphics.Paint; import android.graphics.Shader; Paint circlePaint = new Paint(Paint.ANTI_ALIAS_FLAG); SweepGradient sweepGrad = new SweepGradient(canvas.getWidth()-175, canvas.getHeight()-175,new int[] { Color.RED, Color.YELLOW, Color.GREEN, Color.BLUE, Color.MAGENTA }, null); circlePaint.setShader(sweepGrad); canvas.drawCircle(canvas.getWidth()-175, canvas.getHeight()-175, 100, circlePaint); Q38) How to draw different types of shape in Canvas? You can define and draw primitive shapes such as rectangles and ovals using the ShapeDrawable class in conjunction with a variety of specialized Shape classes.You can define Paintable drawables as XML resource files, but more often, especially with more complex shapes, this is done programmatically. Drawing Different Shapes Some of the different shapes available within the android.graphics.drawable.shapes package include Rectangles (and squares) Rectangles with rounded corners Ovals (and circles) Arcs and lines Other shapes defined as paths Created by: Prof. Adnan Ahmad (9979276001) Page 42 Patel Group of Institutions Subject: Mobile Computing (650003) MCA- Vth Semester a. Drawing Rectangles and Squares: import android.graphics.drawable.ShapeDrawable; import android.graphics.drawable.shapes.RectShape; ... ShapeDrawable rect = new ShapeDrawable(new RectShape()); rect.setIntrinsicHeight(2); rect.setIntrinsicWidth(100); rect.getPaint().setColor(Color.MAGENTA); ImageView iView = (ImageView)findViewById(R.id.ImageView1); iView.setImageDrawable(rect); b. Drawing Rectangles with Rounded Corners: import android.graphics.drawable.ShapeDrawable; import android.graphics.drawable.shapes.RoundRectShape; ... ShapeDrawable rndrect = new ShapeDrawable( new RoundRectShape( new float[] { 5, 5, 5, 5, 5, 5, 5, 5 }, null, null)); rndrect.setIntrinsicHeight(50); rndrect.setIntrinsicWidth(100); rndrect.getPaint().setColor(Color.CYAN); ImageView iView = (ImageView)findViewById(R.id.ImageView1); iView.setImageDrawable(rndrect); c. Drawing Ovals and Circles: import android.graphics.drawable.ShapeDrawable; import android.graphics.drawable.shapes.OvalShape; ... ShapeDrawable oval = new ShapeDrawable(new OvalShape()); oval.setIntrinsicHeight(40); oval.setIntrinsicWidth(100); oval.getPaint().setColor(Color.RED); ImageView iView = (ImageView)findViewById(R.id.ImageView1); iView.setImageDrawable(oval); d. Drawing Arcs: import android.graphics.drawable.ShapeDrawable; import android.graphics.drawable.shapes.ArcShape; ... ShapeDrawable pacMan = new ShapeDrawable(new ArcShape(0, 345)); pacMan.setIntrinsicHeight(100); pacMan.setIntrinsicWidth(100); pacMan.getPaint().setColor(Color.MAGENTA); ImageView iView = (ImageView)findViewById(R.id.ImageView1); iView.setImageDrawable(pacMan); Q39) Different between ViewSwitcher and SlidingDrawer. ViewSwitchers: A ViewSwitcher control contains only two child View objects and only one of those is shown at a time. It switches between the two, animating as it does so. Primarily, the ImageSwitcherand TextSwitcher objects are Created by: Prof. Adnan Ahmad (9979276001) Page 43 Patel Group of Institutions Subject: Mobile Computing (650003) MCA- Vth Semester used. Each one provides a way to set a new child View, either a Drawable resource or a text string, and then animates from what is displayed to the new contents. SlidingDrawer: Another View container is the SlidingDrawer control.This control includes two parts: a handle and a container view.The user drags the handle open and the internal contents are shown; then the user can drag the handle shut and the content disappears.The SlidingDrawer can be used horizontally or vertically and is always used from within a layout representing the larger screen.This makes the SlidingDrawer especially useful for application configurations such as game controls. A user can pull out the drawer, pause the game, change some features, and then close the SlidingDrawer to resume the game. Q40) what is different between MultiAutoCompleteTextView and AutoCompleteTextView? There are two forms of auto-complete. One is the more standard style of filling in the entire text entry based on what the user types. If the user begins typing a string that matches a word in a developer-provided list, the user can choose to complete the word with just a tap.This is done through the AutoCompleteTextView control. The second method allows the user to enter a list of items, each of which has autocomplete functionality .These items must be separated in some way by providing a Tokenizer to the MultiAutoCompleteTextView object that handles this method.A common Tokenizer implementation is provided for comma-separated lists and is used by specifying the MultiAutoCompleteTextView.CommaTokenizer object.This can be helpful for lists of specifying common tags and the like. Q41) Which steps are required for publishing an Android application? The following steps are required for publishing an application: 1) Preparing Your Code to Package: An application that has undergone a thorough testing cycle might need changes made to it before it is ready for a production release.These changes convert it from a debuggable, preproduction application into a release-ready application. 2) Setting the Application Name and Icon: An Android application has default settings for the icon and label.The icon appears in the application Launcher and can appear in various other locations, including marketplaces. As such, an application is required to have an icon. 3) Versioning the Application: Next, proper versioning is required, especially if updates could occur in the future.The version name is up to the developer.The version code, though, is used internally by the Android system to determine if an application is an update.You should increment the version code for each new update of an application. 4) Verifying the Target Platforms: Make sure your application sets the <uses-sdk> tag in the Android manifest file correctly. This tag is used to specify the minimum and target platform versions that the application can run on. 5) Configuring the Android Manifest for Market Filtering: If you plan to publish through the Android Market, you should read up on how this distribution system uses certain tags within the Android manifest file to filter applications available to users. Many of these tags, such as <supportsscreens>, <uses-configuration>, <uses-feature>, <uses-library>, <uses-permission>, and <uses-sdk>. 6) Preparing Your Application Package for the Android Market: The Android Market uses the android:versionName attribute of the <manifest> tag within the Android manifest file to display version information to users. It also uses the android:versionCode attribute internally to handle application upgrades.The android:icon and android:label attributes must also be present because both are used by the Android Market to display the application name to the user with a visual icon. 7) Verifying Application Permissions: Finally, the permissions used by the application should be reviewed. Include all permissions that the application requires, and remove any that are not used. Users appreciate this. Created by: Prof. Adnan Ahmad (9979276001) Page 44 Patel Group of Institutions Subject: Mobile Computing (650003) MCA- Vth Semester Q42) which steps are required for distributing your Android application? I. Distributing Your Applications: Now that you’ve prepared your application for publication, it’s time to get your application out to users—for fun and profit. Unlike other mobile platforms, most Android distribution mechanisms support free applications and price plans. II. Selling Your Application on the Android Market: The Android Market is the primary mechanism for distributing Android applications at this time.This is where your typical user purchases and downloads applications.As of this writing, it’s available to most, but not all,Android devices.As such,we show you how to check your package for preparedness, sign up for a developer account, and submit your application for sale on the Android Market. III. Signing Up for a Developer Account on the Android Market: To publish applications through the Android Market, you must register as a developer.This accomplishes two things. It verifies who you are to Google and signs you up for a Google Checkout account, which is used for billing of Android applications. To sign up for an Android Market developer account, you need to follow these steps: 1. Go to the Android Market sign-up website at http://market.android.com/publish/signup, 2. Sign in with the Google Account you want to use. (At this time, you cannot change the associated Google Account, but you can change the contact email addresses for applications independently.) 3. Enter your developer information, including your name, email address, and website. 4. Confirm your registration payment (as of this writing, $25 USD). Note that Google Checkout is used for registration payment processing. 5. Signing up and paying to be an Android Developer also creates a mandatory Google Checkout Merchant account for which you also need to provide information.This account is used for payment processing purposes. 6. Agree to link your credit card and account registration to the Android Market Developer Distribution Agreement.The basic agreement (U.S. version) is available for review at http://www.android.com/us/developerdistribution-agreement.html. Always print out the actual agreement you sign as part of the registration process, in case it changes in the future. IV. Uploading Your Application to the Android Market: Now that you have an account registered for publishing applications through Android Market and a signed application package, you are ready to upload it for publication. From the main page of the Android Market website (http://market.android.com/publish), sign in with your developer account information V. Upgrading Your Application on the Android Market: You can upgrade existing applications from the Market from the developer account page. Simply upload a new version of the same application using the Android manifest file tag, android:versionCode. Created by: Prof. Adnan Ahmad (9979276001) Page 45