Download presentation
Presentation is loading. Please wait.
1
Android Mobile Application Development
Android Application Components Lecture Three Assistant Lecturer Mustafa Ghanem Saeed Computer science Department Collage Of Science Cihan University - Sulaimaniyah
2
Application Components
Application components are the essential building blocks of an Android application. These components are loosely coupled by the application manifest file AndroidManifest.xml that describes each component of the application and how they interact.
3
What are the main components of Android?
Description Activities They dictate the UI and handle the user interaction to the smart phone screen Services They handle background processing associated with an application. Broadcast Receivers They handle communication between Android OS and applications. Content Providers They handle data and database management issues.
4
Activities This is the main component which user sees, when they run the Application. Activity are responsible for GUI (Graphical User Interface) to user.e.g., Phone dialer is Activity. An activity is implemented as a subclass of Activity class as follows −
5
Service 1 Service: This component is responsible for running long background operations or processes. There is no GUI for service, e.g., Running music is a Service. A service is implemented as a subclass of Service class as follows :
6
Service 2 A service can essentially take two states − State
Description Started A service is started when an application component, such as an activity, starts it by calling startService(). Once started, a service can run in the background indefinitely, even if the component that started it is destroyed. Bound A service is bound when an application component binds to it by calling bindService(). A bound service offers a client-server interface that allows components to interact with the service, send requests, get results, and even do so across processes with interprocess communication (IPC).
7
Broadcast Receiver Broadcast Receiver: This is responsible for events – that listen for or respond to the events. Events are represented by intent class. These intents are then routed to broadcast receiver. E.g SMS message is a broadcast receiver. For sending the message there is one broadcast receiver and for receiving message there is another broadcast receiver. A broadcast receiver is implemented as a subclass of BroadcastReceiver class and each message is broadcaster as an Intent object.
8
Content Provider Content Provider: This component allows multiple applications to store and share data. This is similar to our database style interface although it is responsible for interprocess communications between the Apps. E.g., app uses content providers for viewing inbox mails. A content provider is implemented as a subclass of ContentProvider class and must implement a standard set of APIs that enable other applications to perform transactions.
9
Additional Components
There are additional components which will be used in the construction of above mentioned entities, their logic, and wiring between them. These components are −
10
Android Activity Lifecycle
An activity is the single screen in android. It is like window or frame of Java. Android Activity Lifecycle is controlled by 7 methods of android.app.Activity class. The android Activity is the subclass of ContextThemeWrapper class. By the help of activity, you can place all your UI components or widgets in a single screen.
11
Activity Lifecycle the 7 lifecycle methods of android activity (Question). Method Description onCreate called when activity is first created. onStart called when activity is becoming visible to the user. onResume called when activity will start interacting with the user. onPause called when activity is not visible to the user. onStop called when activity is no longer visible to the user. onRestart called after your activity is stopped, prior to start. onDestroy called before the activity is destroyed.
12
Activity Lifecycle Diagram (Question).
13
Activity Lifecycle (Two activities)
14
Conditions of activity lifecycle
Question: List all lifecycle methods of android activity when (called when the activity creates, visible to users, called when the activity in background, called when the activity finish, called when the activity again comes in foreground)
15
Important Questions? Define Application Components? Ans : Slide 2
What are the main Application components of Android? Ans : Slide 3 Explain Activities in Android Application Components and write sample java code to implement it ? Ans : Slide 4 Explain Service in Android Application Components and write sample java code to implement it ? Ans : Slide 5 Explain Broadcast Receiver in Android Application Components and write sample java code to implement it ? Ans : Slide 7 Explain Content Provider in Android Application Components and write sample java code to implement it ? Ans : Slide 8 A Android Application service can essentially take two state, explain that? Ans : Slide 6 What are the additional Application components of Android? Ans : Slide 9 List lifecycle methods of android activity with short Description? Ans : Slide 11 Drew Activity Lifecycle Diagram? Ans : Slide 12 List only the methods of lifecycle of android activity when: Ans : Slide 14 called when the activity creates, visible to users? called when the activity in background? called when the activity finish? called when the activity again comes in foreground?
16
Questions? Discussion?
Similar presentations
© 2024 SlidePlayer.com. Inc.
All rights reserved.