Mobile Notes
Mobile Notes
Key Facts
• Phones = small, portable computers with touch, sensors, camera, GPS, etc.
• People carry phones everywhere. Most sleep with them. Apps are personal.
Feature Explanation
Short Usage Time Users don’t stay long — app must be quick & clear
• Typing is slow.
• Solution: Make mobile-friendly UIs with fewer items per screen and bigger
buttons.
• They use your app for 10 seconds, then get a call or notification.
• Lightweight
• Fast
• Simple
Native Built only for one Android Studio, Best performance, deep
OS (e.g. Android) Java/Kotlin hardware access
Cross- One code for both Flutter, React Saves time, good for
Platform iOS & Android Native startups
Hybrid Web app inside a Ionic, Cordova Fast dev, less hardware
native wrapper access
2.1 Why You’re Studying Native Apps:
3 Introduction to Android
Main Features:
Tool Purpose
Version Control Git tracks your code changes (important for group projects)
4 Exam Questions
Native apps are built specifically for one platform using official tools like Android
Studio and Java/Kotlin. They give high performance, full access to hardware (like
GPS, camera), and better security. In contrast, hybrid apps are faster to build but
may have lower performance and limited device access.
Mobile apps can be native, web, cross-platform, or hybrid. Native apps like TikTok
(Android) use Java/Kotlin and work only on one OS. Web apps like Facebook (in a
browser) use HTML/CSS/JS and work in browsers. Cross-platform apps like
Airbnb use Flutter or React Native to work on both Android and iOS. Hybrid apps
like Twitter are web apps wrapped in a native shell using tools like Ionic.
Key Revision Flash Points
• Native app = built for one platform → fast + full hardware access
Goal: Understand how to create your first Android app and run it.
Basic Steps:
o App name
o Language (Java/Kotlin)
File Purpose
Part Purpose
Use Design tab for drag-drop, Text tab to edit XML directly.
6 Android Architecture
• Written in C
• Libraries like:
o SQLite (database)
o WebKit (browser)
o SSL (security)
o Activities
o Services
o Notifications
o Content providers
o Window manager
Steps:
Term Meaning
Manifest Allows different settings (like name, min SDK) for each
Merge variant
8.1 Activity
One screen of the app. Controls what user sees and interacts with.
Example:
Background process — no UI. Keeps running even when activity is not open.
Examples:
• Music player
• Download manager
Code:
Examples:
Code:
8.4 Content Provider
Examples:
• Contacts
• Calendar
• Files
Code:
Intents can:
Component Role
Emulator Limitations:
• No camera input
• No Bluetooth
• No battery sensor
• SLOW!
Exam Questions:
“List and explain core Android app components”
Android has four main components: Activities (screens), Services (background
tasks), Broadcast Receivers (event listeners), and Content Providers (data sharing).
These components allow an Android app to run, interact with the system, and
respond to user and system events.
Android architecture has four layers. The bottom layer is the Linux Kernel
(hardware access). The second is Libraries and Runtime (where your code runs).
The third is Application Framework (gives app tools like Activity Manager). The
top layer is Applications, where user apps live.
LECTURE 3
13 Android UI Tour
➤ Home Screen
• This is the first screen you see after unlocking your phone.
• It has:
o Time
o Battery
o Network signal
o Bluetooth, etc.
▪ Wi-Fi Connected
▪ New Email
▪ Music Playing
▪ USB connected
Why?
• You can change app design without touching the Java code.
• Faster updates and cleaner organization.
o Java Code
o XML Layouts
• APK installation: You either download from Play Store or manually install
.apk file.
File Purpose
1. AndroidManifest.xml
→ App starts reading the file. → Finds which Activity is marked as
LAUNCHER (the starting screen).
2. MainActivity.java
→ Code inside onCreate() runs. → It links to the layout file.
3. activity_main.xml
→ Layout file is loaded and displayed.
16.1.1 ➤ MainActivity.java
Example:
16.1.2 ➤ activity_main.xml
• Written in XML.
Example:
16.1.3 ➤ AndroidManifest.xml
Steps:
Folder Purpose
19 Strings in Android
• Instead of hard-coding text inside XML, save them in strings.xml for easy
editing.
Example:
Advantage: Change in one place reflects everywhere!
Example:
22 Screen Dimensions
Term Meaning
DPI Types:
• ldpi (low)
• mdpi (medium)
• hdpi (high)
• xxxhdpi (highest)
LECTURE 4
23 Android UI Design using XML
23.1 Widgets
Widgets = UI components that the user can see and interact with.
Examples:
24.1 TextView
Property Use
ID Usage:
Action Syntax
• A clickable widget.
Example:
24.3 ImageView and ImageButton
24.4 EditText
Example:
24.5 Spinner
• Drop-down list.
Example:
Example:
Example:
24.8 Indicators
Widget Use
ProgressBar Shows loading progress
Important:
4. Avoid Hardcoding Strings: Always put your strings in strings.xml for easy
translation and maintenance.
5. Organizing Images: Put images with different resolutions (mdpi, hdpi,
xhdpi) to make apps look crisp on all devices.
A layout defines how your app's screen looks. It controls where and how UI
elements (buttons, text, images) appear.
What It Does:
Key Attribute:
Example (Vertical):
Weight System – How Space Is Shared:
• If weights are given, the remaining space is shared based on those weights.
Example:
weightSum (Optional)
• Can be used to set total weight (not often needed unless fine-tuning).
29.2 RelativeLayout – Position-Based Layout
What It Does:
Useful Attributes:
Attribute Meaning
Example:
Use When:
What It Does:
• Advanced layout that allows you to place items anywhere, but still clean and
optimized.
• Reduces need for nested layouts (which can slow apps down).
How It Works:
Example:
A. Chains
Types of Chains:
Type Behavior
C. Deleting Constraints
• You can also Delete All Constraints using the button in the UI.
A. include Tag
• If you have a layout you want to reuse in many places, define it once and
include it like this:
• You can build a Circular ImageView for profile pictures using libraries or
by drawing manually.
xml
CopyEdit
<com.example.CircularImageView
android:layout_width="100dp"
android:layout_height="100dp"/>
33 Bonus Tips
• Use ConstraintLayout for most modern apps — it’s better for performance.
34 What is an Activity?
Examples:
Each activity has its own lifecycle, which means Android manages it from creation
to destruction — just like a human life.
2. Zygote contains:
Stack Behavior:
Android calls lifecycle methods automatically when the state of your activity
changes.
onCreate()
• Used to:
o Load layout using setContentView()
onStart()
onResume()
• Called when activity is fully visible and ready for user interaction.
onPause()
• Called when activity is partially hidden (e.g., a dialog shows or a phone call
comes in).
onStop()
onRestart()
onDestroy()
User interacts...
→ onPause() → onStop() → onDestroy()
• onPause() called.
• onStop() called.
When Android destroys and recreates activity (like after rotation), your variables
are lost unless you save them.
39.1 onSaveInstanceState(Bundle outState)
Example:
";
Tip: Add logs in all lifecycle methods to see when each is called.
41 Action Bar
• It shows at the top of your app.
What are the major types of Mobile Applications? Explain with examples.
Answer:
• Cross-platform Apps: One code for both Android and iOS. Example:
Flutter-based Airbnb app.
• Hybrid Apps: Web app inside a native shell. Example: Twitter Mobile App
(old versions).
Answer:
• Hybrid apps are faster to build but lower performance and limited
hardware features.
Answer:
Answer:
Answer:
• Back Button: Destroys the current activity and goes back to previous screen.
Answer:
text
CopyEdit
→ onDestroy()
Each method handles a specific state like initialization, visibility, pause, stop, and
destruction.
• Saves small important data (form entries, scores) before the activity is
destroyed (like during screen rotation).
Answer:
Answer:
Answer:
• Advanced layout that allows placing UI items anywhere with flexible
constraints.
Answer:
Answer:
Method Purpose
Log.e Error
Log.w Warning
Log.i Information
Answer:
Answer:
• A simple way to store small, key-value data (e.g., login status, user name).
• Used when saving basic settings or flags that persist across app sessions.
SECTION B: Practical (Coding/UI
Questions)
43 16. Create a simple Login Screen XML layout with two EditTexts
(Username, Password) and a Button.
44 Answer:
How to open a second Activity when Button is clicked? Write Java/Kotlin
Code.
Answer:
Design a UI with a Spinner (Dropdown) and a Submit Button.
Answer:
Write the Java/Kotlin code to show a Toast message when a button is clicked.
Answer:
How to save the username entered in EditText using SharedPreferences?
Answer: