0% found this document useful (0 votes)
5 views5 pages

Android_notes

Android is an open-source mobile operating system developed by Google, first released in 2008, and is the most widely used mobile OS today. It supports a large ecosystem of applications and is built on a five-layer architecture, with Android Studio serving as the official IDE for development. Key components include UI elements, activity lifecycle management, data storage options, and the need for permissions to access device features.

Uploaded by

farawey903
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)
5 views5 pages

Android_notes

Android is an open-source mobile operating system developed by Google, first released in 2008, and is the most widely used mobile OS today. It supports a large ecosystem of applications and is built on a five-layer architecture, with Android Studio serving as the official IDE for development. Key components include UI elements, activity lifecycle management, data storage options, and the need for permissions to access device features.

Uploaded by

farawey903
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
You are on page 1/ 5

📱 1.

Introduction to Android
What is Android?

 Android is an open-source operating system based on the Linux kernel, designed


primarily for touchscreen mobile devices.
 Developed by Google, first released in 2008.
 Currently, it is the most widely used mobile OS in the world.

Key Features of Android:

 Open Source → Free for manufacturers and developers.


 Customizable UI → Developers can build flexible user interfaces.
 Supports Multiple Devices → Smartphones, tablets, TVs, smartwatches, etc.
 Large App Ecosystem → Millions of apps available on the Google Play Store.
 Multitasking → Run multiple applications simultaneously.
 Regular Updates → Improves security and adds new features.

Comparison of XML and Java in Android Development

Aspect XML (eXtensible Markup Language) Java (or Kotlin)

Defines the UI layout and visual structure of Implements the logic and behavior of the
Purpose
the app. app.

Focus Focuses on what the app looks like. Focuses on what the app does.

Markup language used for declaring static Object-oriented programming language


Type
content. used for dynamic functionality.

Used to define UI components, resources, Used for user interaction, API calls, and
Usage
and layouts. backend logic.

Limited to attributes and components Fully customizable, allowing the creation


Customization
provided by the Android SDK. of custom functionality and behaviors.

Integration Acts as a blueprint; Java references XML References XML-defined UI elements to


Aspect XML (eXtensible Markup Language) Java (or Kotlin)

elements by their IDs to add functionality. implement application behavior.

Tools Edited in Android Studio’s layout editor. Written in the Android Studio code editor.

Parsed at runtime to build the UI, adding Directly executed for efficient
Performance
minor overhead. functionality.

activity_main.xml, MainActivity.java, other logic-related


Key Files
AndroidManifest.xml, resource files. files.

Examples of Buttons, TextViews, layouts, colors, styles, Event handling, API calls, database
Use and strings. interactions, and navigation.

Requires knowledge of programming


Complexity Easier to read and modify for visual design.
concepts for implementation.

Handles static content like layouts and Handles dynamic content and app
Static/Dynamic
resources. behavior.

2. Android Architecture (5 Layers)


Layer Description
1. Linux Kernel Acts as the core; manages hardware and drivers.
Provides pre-built functions (e.g., SQLite for databases, OpenGL for
2. Libraries
graphics).
3. Android Runtime
Executes applications, manages garbage collection.
(ART)
4. Application Provides APIs for developers (e.g., managing UI, resources, and
Framework sensors).
5. Applications User apps like Dialer, Camera, WhatsApp, etc.

3. Android Studio – Official IDE


What is Android Studio?

 Android Studio is the Integrated Development Environment (IDE) for developing


Android applications.
 Built on IntelliJ IDEA.
 Provides tools for designing UI, writing code, testing, and debugging.
Features of Android Studio:

 Layout Editor → Drag-and-drop interface design.


 Code Editor → Auto-complete, error detection.
 Emulator → Simulates Android devices for testing.
 Gradle Build System → Automates building, packaging, and deploying the app.
 Debugging Tools → Helps identify and fix errors.

4. Android Project Structure


Key Folders & Files:

Component Description
manifest (AndroidManifest.xml) App configuration, permissions, components.
java/ Contains Java or Kotlin source code (app logic).
res/layout/ Contains XML files for UI design.
res/drawable/ Images and icons used in the app.
res/values/ Colors, strings, styles, and dimensions.
Gradle Scripts Configuration files for building the project.

5. Android UI Components (Widgets)


Component Description
TextView Displays text to the user (like a label).
EditText Input field for user text input.
Button Clickable button to perform actions.
ImageView Displays images.
CheckBox Allows user to select multiple options.
RadioButton Allows single selection from multiple options.
Switch Toggles ON/OFF state.
ProgressBar Indicates loading or progress.

6. Layouts in Android (UI Design using XML)


Layout Type Description
LinearLayout Arranges components in a horizontal or vertical line.
RelativeLayout Positions components relative to other views.
ConstraintLayout Flexible positioning with constraints (modern layout).
FrameLayout Overlaps views on top of each other.
TableLayout Displays data in rows and columns like a table.

Common Layout Attributes:

Attribute Description
layout_width wrap_content (content size) or match_parent (full width).
layout_height wrap_content or match_parent.
gravity Aligns content inside a view.
padding Space inside a view.
margin Space outside a view.

7. Key Android Components (Building Blocks)


Component Description
Activity Represents a single screen with a UI.
Intent Used to navigate between screens or start services.
Service Runs in the background (e.g., music player).
BroadcastReceiver Listens to system-wide events (e.g., battery low).
ContentProvider Shares data between apps (e.g., Contacts app).

8. Activity Lifecycle (State Changes)


Method When Called
onCreate() When the Activity is first created.
onStart() When the Activity becomes visible.
onResume() When the Activity interacts with the user.
onPause() When the Activity goes partially off-screen.
onStop() When the Activity is hidden from view.
onDestroy() When the Activity is closed/removed from memory.

9. Event Handling (Example: Button Click)


Java Code Example:
Button myButton = findViewById(R.id.myButton);
myButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Toast.makeText(MainActivity.this, "Button Clicked!",
Toast.LENGTH_SHORT).show();
}
});

10. Data Storage in Android


Storage Option Usage
SharedPreferences Store small data like settings.
SQLite Database Store structured data like user information.
Files Save text or images in internal storage.

11. Android Permissions


 Apps require permissions to access certain device features (e.g., camera, location,
contacts).
 Defined in AndroidManifest.xml:

<uses-permission android:name="android.permission.CAMERA"/>

12. Common Errors and Debugging


Error Message Possible Cause & Solution
R.layout.activity_main not found Clean and Rebuild Project.
App Crashes Check Logcat for detailed error messages.
UI Changes Not Visible Invalidate Caches / Restart Android Studio.

You might also like