0% found this document useful (0 votes)
2 views6 pages

Project Structure & Intent

The document provides an overview of mobile application development, specifically focusing on the structure of an Android app, including the AndroidManifest.xml, Kotlin folder, and XML folder for UI design. It also compares testing methods using an emulator versus a real device, discusses debugging tools like Logcat, and explains explicit and implicit intents for navigating between activities and passing data. Additionally, it covers how to open system applications using common implicit intents.

Uploaded by

zoya.anees1
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views6 pages

Project Structure & Intent

The document provides an overview of mobile application development, specifically focusing on the structure of an Android app, including the AndroidManifest.xml, Kotlin folder, and XML folder for UI design. It also compares testing methods using an emulator versus a real device, discusses debugging tools like Logcat, and explains explicit and implicit intents for navigating between activities and passing data. Additionally, it covers how to open system applications using common implicit intents.

Uploaded by

zoya.anees1
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd

Mobile Application Development

1. Project Structure (The Anatomy of an


Android App)
Manifests ([Link])
 Concept:

This is the "Identity Card" or the "Blueprint" of your application. The Android Operating
System reads this file first to understand what the app contains.

 Key Points:
o It defines essential app metadata, such as the app's name, launcher icon, and main
theme.
o Every single Activity (screen) created in the app must be registered here;
otherwise, it will not open.
o Permissions: If the app needs to access hardware or external data (like the
Internet, Camera, or Gallery), the request must be declared in this file.

Kotlin Folder:

 Concept:

This folder acts as the "Brain" of your application. It houses all the logical and functional code.

 Key Points:

 [Link]:

This is the default Kotlin file where the execution of your app begins. It is backend logic,
such as what happens when a button is clicked or how data is processed. It’s entirely
controlled by the files inside this directory.

 .XML Folder:

 Concept:

This is the visual and presentation layer of the app. Anything related to the user interface (UI)
and design lives here.
 Main Sub-folders:

 layout/: Contains XML files (e.g., activity_main.xml). This is where the Screen
Design takes place using UI components like buttons, text fields, and images.
 drawable/: Stores all graphic assets, such as images, vector assets, and custom
shapes/icons.
 values/: Contains configuration files like [Link] (for app text), [Link] (for
color palettes), and themes to keep the code clean and reusable.

2. Emulator vs. Real Device (Running the App)


When testing an application, students can choose between two primary methods:

Feature Android Emulator (Virtual Device) Real Device (Physical Android Phone)

A virtual, simulated smartphone


A physical, actual Android smartphone
What is it? running directly inside your
connected to your computer.
computer.

Created and configured inside Requires enabling Developer Options and


Setup Android Studio using the Device turning on USB Debugging in the phone's
Manager (AVD Manager). settings.

Resource-heavy. If the computer has


Extremely fast and lightweight. It puts zero
Performance low RAM, the emulator can severely
load on the computer's RAM/CPU.
slow down the system.

Ideal for testing the app on different Crucial for testing real-world hardware
Testing Use-
screen sizes and Android versions features like the Camera, GPS, hardware
case
(e.g., Pixel, Samsung layouts). sensors, and battery consumption.

Lecture Tip: Students with 8GB of RAM or less on their laptops to strictly use a Real
Device. This prevents Android Studio from freezing or lagging during development.

3. Debugging Tools: Logcat (Finding Errors)

 Concept:
Logcat is the "Black Box" or system log of Android Studio. While the app is running,
Logcat prints out everything happening in the background, including system messages and
explicit errors when an app crashes.

 How to use it:


o The Logcat tab is located at the bottom panel of Android Studio.
o When an app crashes, a detailed crash report called a Stack Trace appears in Red
Text. Teach students that reading this red text is the fastest way to identify the
exact line of code causing the issue.

Explicit vs. Implicit Intents


In Android, Intent is an asynchronous message that allows application components to request
functionality from other Android components. Think of it as a messenger that carries a request to
start a new screen or action.

Explicit Intents

 Concept:

Used to launch a specific component (usually a screen/Activity within your own app) by
explicitly naming the target class.

 Analogy:

Sending a letter to someone by writing their exact home address. You know exactly who should
receive it.

 Key Use Case:

Navigating from MainActivity to a ProfileActivity inside your own application.

 Kotlin Example:

Kotlin

val intent = Intent(this, ProfileActivity::[Link])


startActivity(intent)

Important Note:
ProfileActivity::[Link] uses the .java extension because, even
though we write code in Kotlin, the underlying Android framework still
compiles down to communicate with Java bytecode. If they forget to add
::[Link] at the end, Android Studio will throw a compiler error.

Implicit Intents

 Concept:

Used when you declare the action you want to perform, but you do not know which specific
application or component on the device will handle it. The Android system filters all installed
apps to find the best match.

 Analogy:

Standing in a crowded room and shouting, "Is there a doctor here?" Anyone with a doctor's
qualification can step forward.

 Key Use Case:

Opening a website link, taking a picture, or sharing text via external apps.

 Kotlin Example:

Kotlin

val intent = Intent(Intent.ACTION_VIEW,


[Link]("[Link]
startActivity(intent)

Passing Data Between Activities:


When moving from one Activity to another, you often need to send data along with the Intent.
This is achieved using Extras.

How it Works (Key-Value Pairs)

Data is sent as a bundle of Key-Value pairs. The sender attaches the data using a unique "Key"
(a string identifier), and the receiver extracts the data using that exact same "Key".

Step 1: Sending Data (From FirstActivity)

Use the .putExtra() method on your intent instance before starting the activity.

Kotlin

val intent = Intent(this, SecondActivity::[Link])


[Link]("USER_NAME", "John Doe") // "USER_NAME" is the key, "John Doe"
is the value
[Link]("USER_AGE", 22)
startActivity(intent)

Step 2: Receiving Data (In SecondActivity)

Retrieve the data in the onCreate() method of the destination activity using the appropriate
type-specific getter method (getStringExtra, getIntExtra, etc.).

Kotlin

val name = [Link]("USER_NAME")


// Provide a default value (e.g., 0) for primitive types in case the key is
missing
val age = [Link]("USER_AGE", 0)

Opening System Apps (Common Implicit Intents)


Teach students how to leverage pre-installed system applications instead of building complex
features from scratch.

A. Opening the Web Browser

Launches the device's default web browser to view a specific URL.

Kotlin

val browserIntent = Intent(Intent.ACTION_VIEW,


[Link]("[Link]
startActivity(browserIntent)

B. Opening the Phone Dialer

Opens the default phone dialer screen with a specific phone number pre-filled.

Note: ACTION_DIAL does not require runtime permissions because it only populates the dialer; it
does not make the actual call automatically.

Kotlin

val dialIntent = Intent(Intent.ACTION_DIAL, [Link]("[Link]


startActivity(dialIntent)

C. Opening the System Camera


Requests the system camera app to take a photo. To capture the actual photo file result back into
your app, developers typically use the modern ActivityResultContracts. However, to simply
launch the camera application:

Kotlin

val cameraIntent = Intent(MediaStore.ACTION_IMAGE_CAPTURE)


startActivity(cameraIntent)

You might also like