0% found this document useful (0 votes)
4 views2 pages

Andriod Basics

The document outlines the structure and functionality of an Android application, emphasizing the importance of activity lifecycle management and hardware compatibility. It describes the roles of XML for layout design and Java for functionality, as well as the MVC architecture involving Model, View, and Controller components. Key lifecycle methods such as onCreate, onStart, onResume, onPause, onStop, onRestart, and onDestroy are explained in relation to user interaction and memory management.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4 views2 pages

Andriod Basics

The document outlines the structure and functionality of an Android application, emphasizing the importance of activity lifecycle management and hardware compatibility. It describes the roles of XML for layout design and Java for functionality, as well as the MVC architecture involving Model, View, and Controller components. Key lifecycle methods such as onCreate, onStart, onResume, onPause, onStop, onRestart, and onDestroy are explained in relation to user interaction and memory management.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 2

Application will start in main activity, just like homepage of your app

=> a series of activities /pages

Different phones will have different hardware compatibility depends on the model of
phone they are and the manufacturer. => We could check the hardware capability (for
ex: if ur app requires using camera but the phone model doesn't have it then we
could make another way for the user to still be able to use that feature without
camera or we can just simply turn the feature off.

iPhone is different is just worried about model and type like iPad that's it not
like Android.

There 2 files:
One for visual editing - *.xml defines layout - structure
One for functionality - *.java defines functionality - code

Intent
Unit of ur app
Contain information if its active or ointment background in your app

Activity Lifecycle describe different state that an activity could be in


1. onCreate - initialize variable, extends objects
2. When that activity becomes visible to the user then that onStart() is called
3. OnResume() - Activity now start to interact with user, at this point the
activity will also be on top of the activity STACK !
=> activity running
=> But when the activity lost the user focus on it and run in the background (for
ex: u clicked on another window and that previous window display behind because you
are putting focused on another window => onPaused() will be called for that BEHIND
or run in background WINDOW
=> And when that BEHIND activity get the user focus again => it will not be
recreated but instead just jumped right back into onResumed() function again.
5. When the activity is no longer visible to the user then onStop() is called so
this means maybe a new activity is STARTED FROM OUR CURRENT ACTIVITY OR that our
account activity was destroyed the system.

=> and then when app WITH HIGHER PRIORITY than your app NEED MEMORY then it can
happen that the system could KILL YOUR APP (app process killed) -> the lifecycle
will start with onCreated() again if the user navigates back to our activity
=> in this case, we could not jumped ack to onResume or onStart -> recreate the
whole lifecycle again

NOTE: That's why if you want to save some data -> save in onPaused not onStop bc
onStop is guaranteed to be called

6. When the activity is onStop() but user navigate back to it then onRestart() will
be called and then jumps wight back to onResume()
7. When the user exits the app by the back button or the system destroys it then
onDestroy() is called

View is super class of every layout element in andriod

MVC
Model - User.java
=> Display những data lên View cho ng dùng và chưa rules của data như isValidEmail
hay isValidPassword
View - activity_main.xml
=> Display UI for user interaction (login, inputing text)

Controller - MainActivity.java
=> Listen user interaction (nhập username vào form và click login)
=> Nó sẽ lắng nghe action đó (clickLogin()) và get data nhập manually của user
=> truy xuất đến Model User và initialize new User object (model) "User user = new
USer(email, password)"
=> sau đó nó thực hiện 1 action j đó....

You might also like