Document Details

PrestigiousNephrite1587

Uploaded by PrestigiousNephrite1587

Aswan University

Tags

Android development Java programming Mobile application development

Summary

This document provides an overview of Android development, including its history, components, and practical uses.

Full Transcript

Android Development Java for Android Applications Developement Table of contents 0 0 0 1 2 3 Introduction Android Studio Android IDE Components 0...

Android Development Java for Android Applications Developement Table of contents 0 0 0 1 2 3 Introduction Android Studio Android IDE Components 0 0 0 4 5 6 UI Design Deployment Practical Part What is Android Development It is about creating applications for mobile, specifically Android, devices to be used to assist or serve for a certain purpose 0 1 Introduction What is Android? It is an open source and Linux-based operating system for mobile devices such as smartphones and tablet computers It is involved in other marketplaces like TVs, and wearables. It was developed by the Open Handset Alliance, led by Google It supports multitasking, allowing users to run multiple apps simultaneously Why Android? Market Dominance Open Source The largest installed base of any Android is based on the Linux mobile platform and growing fast kernel and offers flexibility for developers. Open-source code encourages innovation and customizations. Versatile Global Reach Development Access to billions of users via Supports Java, Kotlin, and C++. Google Play Store. Cross-platform frameworks like Devices available at all price Flutter points make Android apps Extensive libraries and APIs for accessible worldwide integrating modern features (e.g., AI/ML) Seamless integration with Google services Categories of Android Applications Android History and API Level Version SDK/ API level Version code Codename Year Android15 Level 35 VANILLA_ICE_CREAM VanillaIceCream 2 2024 API Level is an integer value that Android14 Level 34 UPSIDE_DOWN_CAKE UpsideDownCake 2 uniquely identifies the framework API Android14 targetSdkwill needtobe34+fornewappsandappupdatesbyAugust31, 2024. 2023 revision offered by a version of the Android13 Level 33 TIRAMISU Tiramisu 2 Android13 targetSdkmustbe33+fornewappsandappupdatessinceAugust31, 2023. Android platform. Android12 Level 32 Android12L S_V2 2022 The framework API consists of: Android12 Level 31Android12 S SnowCone 2 2021 ○ A core set of packages and classes Android11 Level 30 R RedVelvetCake 2 2020 Android10 Level 29 Q QuinceTart 2 2019 ○ A set of XML elements and Android9 Level 28 P Pie 2018 attributes for declaring a manifest Android8 Level 27Android8.1 O_MR1 file Android8 Level 26Android8.0 O Oreo 2017 Android7 Level 25Android7.1 N_MR1 ○ A set of XML elements and Android7 Level 24Android7.0 N Nougat 2016 attributes for declaring and Android6 Level 23 M Marshmallow accessing resources Android5 Level 22Android5.1 LOLLIPOP_MR1 2015 ○ A set of Intents Android5 Level 21Android5.0 LOLLIPOP, L Lollipop Jetpack/AndroidXlibrariesrequireaminSdkof21or Anh droid igher5sinceApril 2024. JetpackComposerequiresaminSdkof21orhigher. GooglePlayservicesv23.30.99+( ○ A set of permissions that Android4 Level 20 Android4.4W3 KITKAT_WATCH 2014 applications can request, as well Android4 Level 19 Android4.4 KITKAT KitKat as permission enforcements Jetpack/AndroidXlibraries Android require 4 aminSdkof19orhighersinceOctober2023. GooglePlayservicesv21.33.56+(July2021) dropssuppo Android4 Level 18Android4.3 JELLY_BEAN_MR2 2013 included in the system Android4 Level 17Android4.2 JELLY_BEAN_MR1 Android4 Level 16Android4.1 JELLY_BEAN JellyBean Each Android platform version supports Android 4 Android4 exactly one API Level, although support Android4 ICE_CREAM_SANDWICH is implicit for all earlier API Levels (down Android4 Android History and API Level (Cont’d) The following attributes are declared in an application's manifest inside element or build.gradle file: ○ android:minSdkVersion — Specifies the minimum API Level on which the application is able to run. The default value is "1". ○ android:targetSdkVersion — Specifies the API Level on which the application is designed to run. In some cases, this allows the application to use manifest elements or behaviors defined in the target API Level, rather than being restricted to using only those defined for the minimum API Level. ○ android:maxSdkVersion — Specifies the maximum API Level on which the application is able to run. A manifest file includes the nodes that define the application components, security settings, test classes, permissions, and requirements that make up the application. 0 2 Android Studio IDE Application Development Tools Development Tools Comparison Aspect Native Development (Java/Kotlin) Cross-Platform Development (Flutter/React Native) Platform Android-specific (Java/Kotlin for Android) Supports multiple platforms (Android, iOS, Web, Desktop) Performance Best performance, optimized for Android hardware Slightly lower performance than native, but close to native Development Speed Slower due to separate codebases for each platform Faster development with shared codebase across platforms User Interface Customizable UI, highly platform-specific Limited customization for platform-specific UI but improving Mature ecosystem, extensive libraries and tools for Ecosystem/Community Android Growing community, large ecosystem Learning Curve Steeper for beginners (especially Java) Easier for web developers (React Native uses JavaScript) Codebase Maintenance Separate codebases for Android and iOS Single codebase for all platforms Access to most APIs, but may require additional plugins for Platform-Specific APIs Direct access to platform APIs and hardware some App Size Typically smaller size for Android apps Larger app size due to inclusion of cross-platform libraries High-performance apps, apps requiring deep Apps that need to run on multiple platforms with a single Popular Use Cases integration with Android codebase Examples Instagram, Google Maps, WhatsApp Google Ads, Alibaba, Instagram (React Native) EXtensible Markup Language EXtensible Markup Language (XML) is a markup language used to store and transport data in a structured format. Allows the definition of custom tags. Tag-based syntax (similar to HTML). Human-readable format. Platform-independent (works across various platforms). Data is separated from presentation (focus on content, not design) Used in web services, APIs, configuration files, etc. Used to define UI layouts and configuration files in Android applications Android Studio IDE We will develop Android applications in the Java language using the Android Software Development Kit (SDK) in Android Studio Android Studio is the official Integrated Development Environment (IDE) for Google’s Android operating system, built on JetBrains’ IntelliJ IDEA software and designed specifically for Android development. Android Studio – File Structure AndroidManifest.x ml Java File Layout Drawable File Defines essential Contains the Java Defines the UI Stores graphical information about the code for the app’s structure (views, resources like app, such as its logic and behavior. widgets, etc.) in XML images, icons, or components (activities, This includes format. It determines shapes that can be services), permissions, activities, services, how the user interface used in the app's UI and app configuration. and other app is arranged components colors.xml strings.xml build.gradle Mipmap File File File File Stores app launcher Defines the colors used Stores text strings Contains the build icons in different throughout the app, used in the app, configuration for the resolutions for various allowing easy color allowing for easier app module, such as screen densities (hdpi, management and localization and dependencies, SDK mdpi, etc.) reusability in UI management of text versions, and other components project settings Android Studio – File Structure AndroidManifest.x manifest ml s buil activites app d src/ drawable activity_main.x main ml java … layout res Gradl colors.xml e mipmap strings.x script ml s values styles.xml build.gradle Code Examples 0 3 Android Components Android Components They are the necessary building blocks that an Android application consists of. Activity Service Content Provider Represents a single A component that Manages access to screen with a user runs in the shared data between interface (UI). background without a apps. Controls the UI and UI. Allows different apps user interaction. Handles long-running to read and write to Every app must have tasks like a shared database, at least one activity, downloading files or files, or even other usually a playing music. data sources. MainActivity. Can run even if the Examples include app is not in the contacts, media files, Android Components (Cont’d) Intent Fragment Used to facilitate Represents a portion of a UI communication between or behavior that can be different components reused within an activity. (activities, services, or A way to modularize the UI broadcast receivers). and functionality of an Can be explicit (targeting a activity. specific component) or implicit Can be added, removed, or (indicating the action to be replaced dynamically performed, without specifying during runtime. the component, e.g., open link App component in Android Studio For each app component that you create in your app, declare a corresponding XML element in the manifest file: ○ for each subclass of Activity ○ for each subclass of Service ○ for each subclass of BroadcastReceiver ○ for each subclass of ContentProvider 0 4 UI Design Layouts Each activity will have a layout (UI) and a code (logic for interacting with the activity; functionality) Layouts define the structure and arrangement of UI elements on the screen. Used to create a user-friendly interface by arranging widgets like TextViews, Buttons, and Images. Common Layout Types: ○ LinearLayout: Arranges UI elements in a single row or column ○ RelativeLayout: Positions elements relative to each other or the parent container Example: A Button positioned below a TextView ○ ConstraintLayout: A flexible layout for complex designs Attributes (Layout & View) Attributes define the properties of UI elements or layout components. The syntax for attributes Namespace: ○ android: : Specify attributes provided by the Android SDK ○ app: : Attributes specific to libraries (e.g., ConstraintLayout, Material Design) Example of attribute name: layout_width, text, background Example of attribute value: dimensions -> "match_parent", strings, or references -> "@string/app_name“ Syntax for a reference ○ android:id="@+id/textView1": Assigns a unique/new ID to the TextView. ○ android:text="@string/hello_world": Sets the text from the strings resource. ○ app:layout_constraintTop_toTopOf="parent": Sets a constraint using the app namespace. Size Units Different units are used in Android layouts for defining dimensions, margins, padding, and text sizes Unit Use Case Scales Density-independent Pixels Dimensions (width, height, Yes - based on the screen's (dp) margins) density Yes - Respects the user's font Scale-independent Pixels (sp) Text sizes size preferences Pixel (px) Exact pixel dimensions No Relative dimensions in Percent (%) Yes ConstraintLayout View Elements Each component in the screen is called a Common Attributes: View android:hint, android:inputType They represent visual components ○ Button displayed on the screen A clickable UI element for Layout is like container or box to contain performing actions the views Example: Submit, Cancel Example: buttons ○ TextView Common Attributes: Displays text to the user android:text, android:onClick Example: Titles, labels, or ○ ImageView paragraphs Displays images or icons Common Attributes: Example: App logo or photos android:text, android:textColor, Common Attributes: android:textSize android:src, android:scaleType ○ EditText ○ CheckBox An input field where users can A box that can be checked or enter text unchecked to select an option Example: Username and Example: Agree to terms and password fields conditions Intents Intents are messaging objects that allow communication between components Provide inter-component communication and enable users to perform actions Types of Intents: ○ Explicit Intent: Directly specifies the target component (e.g., opening another activity in the same app) Example: Navigate from one screen to another ○ Implicit Intent: Does not specify the target component. The system determines the appropriate app or component to handle the request Example: Sharing content or opening a URL Components of an Intent: ○ Action: Specifies the operation to perform (e.g., Intent.ACTION_VIEW). ○ Data: URI or other data to act upon (e.g., a phone number or URL). ○ Extras: Key-value pairs to pass additional information. ○ Category: Provides additional information about the action. ○ Flags: Define how an intent should behave (e.g., launching in a new task). Common Actions: ○ Call a number: Intent.ACTION_CALL. ○ Send email: Intent.ACTION_SEND. ○ Pick an item: Intent.ACTION_PICK (e.g., from the gallery). Activity Life Cycle 0 5 Deployment Deployment To test your app in a development environment Involves running the app directly on a device or emulator via tools like Android Studio Does not involve signing the app with a release key or preparing it for end-users Typically uses a debug build that includes debugging tools, logs, and no optimizations Examples: ○ Running your app on a connected physical Android device using USB. ○ Running your app on an Android Virtual Device (AVD) in the emulator App Release To distribute the app to end users through platforms like Google Play or other channels. Involves creating a release build: ○ Signed with a release key. ○ Optimized and stripped of debugging tools. ○ Often includes code obfuscation for security. Outputs: APK or AAB files ready for distribution. Examples: ○ Generating a signed APK using Android Studio's Build menu. ○ Uploading the APK/AAB to the Google Play Console for review and publishing. 0 6 Practical Part Last Words The XML file deals with the design, presentation, layouts, blueprint, etc (as a front-end) while the java deals with working of buttons, variables, storing, etc (as a back-end).

Use Quizgecko on...
Browser
Browser