100% satisfaction guarantee Immediately available after payment Both online and in PDF No strings attached 4.2 TrustPilot
logo-home
Summary

Summary Activity Lifecycle: CSC2002S Mobile Design and Development Module (MDD)

Rating
-
Sold
-
Pages
2
Uploaded on
17-10-2022
Written in
2022/2023

These notes cover the sections: Android, activity lifecycle, design principles, evaluation, everyday design, views, widgets, layouts, security, software architecture, understanding users and ideas, prototypes, products. These are all the topics you need to ace the MDD section of the exam, which is 33.3% of the paper.

Show more Read less
Institution
Course








Whoops! We can’t load your doc right now. Try again or contact support.

Written for

Institution
Course

Document information

Uploaded on
October 17, 2022
Number of pages
2
Written in
2022/2023
Type
Summary

Subjects

Content preview

// set the user interface layout for this activity
// the layout file is defined in the project res/layout/main_activity.xml file setContentView(R.layout.main_activity)
// initialize member TextView so we can manipulate it later
Activity Lifecycle
textView = findViewById(R.id.text_view)
}
// This callback is called only when there is a saved instance that is previously saved by using onSaveInstanceState().
→ The different states (that your application can move through) and callbacks helps the OS to manage resources and // We restore some state in onCreate(), while we can optionally restore other state here, possibly usable after onStart() has complete
// The savedInstanceState Bundle is same as the one used in onCreate().
application interrupts.
override fun onRestoreInstanceState(savedInstanceState: Bundle?) {
**KNOW & UNDERSTAND THESE STATES
textView.text = savedInstanceState?.getString(TEXT_VIEW_KEY)
}
** REFER TO SLIDES FOR EXAMPLES:
// invoked when the activity may be temporarily destroyed, save the instance state here
override fun onSaveInstanceState(outState: Bundle?) {
outState?.run {
https://s3-us-west-2.amazonaws.com/secure.notion-static.com/33dd8baf-86f3-4d89-bad4-7e08dae67ae2/MDD07-activit putString(GAME_STATE_KEY, gameState) putString(TEXT_VIEW_KEY, textView.text.toString())
ies.pdf }
// call superclass to save any view hierarchy
super.onSaveInstanceState(outState)
}
→ Extend the base activity class
→ Override functions
→ Only implement functions that you need
→ Call the super class method
→ Pay attention to what you re building and destroying
→ What part of the lifecycle is the app currently in?
Activity lifecycle methods are called automatically depending on
the OS needs and the stage they are in.
Initiate the UI in onCreate() User Navigation
Use onSaveInstanceState() and onRestoreInstanceState() to Handle Home and Back buttons gracefully
preserve state
It’s important to distinguish between the navigation buttons
Most users don’t know the difference – be gracious!
Interruptions: Lifecycle management is especially important
due to resource management constraints Home button
Calls onStop(), onStart()
The app is stopped but not destroyed
Implementing Activities
Back button
The Activity Class
Goes back to previous activity (unless you’ve overridden this)
Calls onStop(), onDestroy()
lateinit var textView: TextView
// some transient state for the activity instance Important when implementing multiple Activities (data retention)
var gameState: String? = null
override fun onCreate(savedInstanceState: Bundle?) {
// call the super class onCreate to complete the creation of activity like // the view hierarchy Screen Rotation
super.onCreate(savedInstanceState)
→ Your Activity will be destroyed and recreated each time the screen rotates. Needs to re-render & re-build the screen
// recovering the instance state based on the new screen layout.
gameState = savedInstanceState?.getString(GAME_STATE_KEY)
Activity Lifecycle 1 Activity Lifecycle 2
$3.04
Get access to the full document:

100% satisfaction guarantee
Immediately available after payment
Both online and in PDF
No strings attached


Also available in package deal

Get to know the seller

Seller avatar
Reputation scores are based on the amount of documents a seller has sold for a fee and the reviews they have received for those documents. There are three levels: Bronze, Silver and Gold. The better the reputation, the more your can rely on the quality of the sellers work.
chloewalt University of Cape Town
Follow You need to be logged in order to follow users or courses
Sold
24
Member since
3 year
Number of followers
12
Documents
36
Last sold
2 weeks ago

4.8

6 reviews

5
5
4
1
3
0
2
0
1
0

Recently viewed by you

Why students choose Stuvia

Created by fellow students, verified by reviews

Quality you can trust: written by students who passed their tests and reviewed by others who've used these notes.

Didn't get what you expected? Choose another document

No worries! You can instantly pick a different document that better fits what you're looking for.

Pay as you like, start learning right away

No subscription, no commitments. Pay the way you're used to via credit card and download your PDF document instantly.

Student with book image

“Bought, downloaded, and aced it. It really can be that simple.”

Alisha Student

Frequently asked questions