Mobile Programming - Quick Notes
Mobile Programming - Quick Notes
1. Activity Lifecycle (VERY Important):
onCreate() -> onStart() -> onResume() -> [Running]
-> onPause() -> onStop() -> onDestroy()
Simple Nepali:
- onCreate(): App ■■■■ ■■■■■ ■■■■■ function ■■■
- onStart(): User ■■■ ■■■■■■ ■■■■ ■■■■■■■■
- onResume(): User ■■ interact ■■■■ ■■■■■
- onPause(): ■■■■■ activity ■■■■■■■
- onStop(): ■■ screen ■■ ■■■■■■■■■
- onDestroy(): Memory ■■■ ■■■■■■■■
2. Android Components:
- Activity: UI screen
- Service: No UI, runs in background
- BroadcastReceiver: Respond to system messages
- ContentProvider: Share data between apps
3. Intents:
Explicit:
Intent i = new Intent(this, [Link]);
startActivity(i);
Implicit:
Intent i = new Intent(Intent.ACTION_VIEW);
[Link]([Link]("[Link]
startActivity(i);
4. Layouts:
- LinearLayout: Vertical/horizontal line
- RelativeLayout: Position based on other items
- ConstraintLayout: Modern, flexible
5. SQLite Example:
SQLiteDatabase db = openOrCreateDatabase("StudentDB", MODE_PRIVATE, null);
[Link]("CREATE TABLE IF NOT EXISTS student(id INTEGER, name TEXT);");
[Link]("INSERT INTO student VALUES(1, 'Bibek');");
6. Permissions:
<uses-permission android:name="[Link]"/>
7. Android vs iOS:
Android: Open-source, Java/Kotlin, many devices
iOS: Closed, Swift, Apple only
8. Sample Code: Button click to show text:
Button b = findViewById([Link]);
TextView t = findViewById([Link]);
[Link](v -> [Link]("Button Clicked"));