Andriod Basics
Andriod Basics
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
=> 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
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 đó....