The document provides an overview of key concepts in Android development, including the definitions of Activity, Android SDK, and the Open Handset Alliance. It explains the role of XML files in UI design, the importance of the Android Manifest file, and the function of various resources such as Drawables and Layouts. Additionally, it covers different types of Intents and the anatomy of an Android application, highlighting the structure and components necessary for app development.
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0 ratings0% found this document useful (0 votes)
2 views20 pages
Android Chapter 1
The document provides an overview of key concepts in Android development, including the definitions of Activity, Android SDK, and the Open Handset Alliance. It explains the role of XML files in UI design, the importance of the Android Manifest file, and the function of various resources such as Drawables and Layouts. Additionally, it covers different types of Intents and the anatomy of an Android application, highlighting the structure and components necessary for app development.
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 20
Android Chapter 1
[Q-1]
(A)
1. What is an Activity? ➢ An Activity is a single screen with a user interface in an Android application.
2. Full form of OHA:
➢ OHA stands for Open Handset Alliance.
3. What is Android SDK?
➢ Android SDK is a Software Development Kit that provides tools and libraries to develop Android applications.
4. Full form of SDK:
➢ SDK stands for Software Development Kit.
5. What is Open Handset Alliance?
➢ Open Handset Alliance (OHA) is a group of companies that developed open standards for mobile devices, led by Google. 6. What is Android Studio? ➢ Android Studio is the official Integrated Development Environment (IDE) for Android app development.
7. OHA was established in the year ____________.
➢ 2007
8. Layout is an Android service: True/False
➢ False (B)
1. Explain giving example: Context in Android
➢ Context is an important class in Android that provides access to application-specific resources and classes. ➢ It allows components like Activities, Services, and Broadcast Receivers to communicate with the Android system. ➢ With Context, we can access resources (like strings, images), databases, shared preferences, and system-level services such as location services, notification managers, and more. ➢ Context also helps in launching new activities, sending broadcasts, and interacting with system components. It acts as a bridge between the Android system and app components. ➢ There are mainly two types of Context in Android: o Application Context – Refers to the entire application life cycle. It is used when we need a context that lasts as long as the app is alive. o Activity Context – Refers to a single activity and is tied to the activity lifecycle. It should be used when operations are limited to an activity. ➢ Example: o Activity, Service, and Application classes are subclasses of Context. o For example, to display a Toast message, we need a Context: o Toast.makeText(getApplicationContext(), "Welcome to Android!", Toast.LENGTH_SHORT).show(); 2. What is the use of XML file in Android? ➢ XML (eXtensible Markup Language) is used in Android for designing the user interface (UI) and for storing structured data in a readable format. ➢ XML helps separate the UI design from the application logic written in Java. ➢ Main uses of XML in Android: o Layout Design: ▪ XML is used to define the layout of Android screens (activities and fragments). ▪ Example: Defining buttons, text views, images, etc., inside .xml files located in the res/layout folder. o Resource Management: ▪ XML is used to store various resources like strings (strings.xml), colors (colors.xml), dimensions (dimens.xml), and styles (styles.xml), making the app easier to manage and localize. o Manifest File: ▪ The AndroidManifest.xml file contains essential information about the app like its components (activities, services), permissions, and app metadata. o Drawable and Animation: ▪ XML is used to create custom shapes, gradients, and animations stored in res/drawable and res/anim folders. 3. What is Drawable? How it is useful in developing applications? ➢ Drawable is a graphic or image resource that can be drawn on the screen. It is used to display shapes, images, colors, and other graphics in Android applications. ➢ Drawables are stored in the res/drawable directory and can include bitmap images (PNG, JPG), vector images (SVG as XML), shapes, gradients, and more. ➢ Uses of Drawable: o Custom Graphics: ▪ Developers can create custom shapes, like rectangles, ovals, and lines, using XML in drawable files. ▪ Example: Making rounded buttons, borders, and backgrounds. o Image Handling: ▪ Storing and using images and icons (e.g., logo, icons, background images) in a centralized way. o State-based Graphics: ▪ Creating selectors to change button appearance on different states (normal, pressed, focused). o Animations: ▪ Drawables are used to create frame-by-frame animations and transitions. 4. What is Android Manifest File? Explain its usefulness. ➢ The AndroidManifest.xml file is an essential file in every Android application that provides important information about the app to the Android operating system. ➢ It is located in the root directory of the app's project structure and acts as a bridge between the Android system and the app. ➢ Usefulness of Android Manifest File: o Declares Application Components: ▪ It declares all components of the app such as Activities, Services, Broadcast Receivers, and Content Providers, so that the system knows how to interact with them. o Defines Permissions: ▪ It specifies the permissions the app needs to function, like accessing the internet, camera, location, etc. o Specifies App Metadata: ▪ It provides general information about the app, like app icon, app name, version, and theme. o Declares Intents and Filters: ▪ It defines intent-filters to specify how components interact and respond to system or app events (like launching an activity). 5. Explain in detail: Emulator ➢ An Emulator is a virtual device that simulates a real Android device on a computer. It allows developers to test and run Android applications without using a physical device. ➢ The Emulator is a part of Android Studio and is used during the development and debugging process. ➢ Explanation and Uses of Emulator: o Testing Applications: ▪ The Emulator provides a platform to test apps on different Android versions, screen sizes, and device configurations (like phones, tablets, and wearables). ▪ It helps to ensure that the app runs smoothly on various devices without needing actual hardware. o Simulating Hardware Features: ▪ The Emulator can simulate hardware features such as GPS, battery, sensors, camera, and phone calls, which are useful for testing specific app functionalities. o Cost-Effective: ▪ It removes the need for purchasing multiple physical devices, thus saving cost and making the development process efficient. o Faster Development and Debugging: ▪ With tools integrated in Android Studio, developers can quickly run, test, and debug apps directly on the Emulator, speeding up the development process. 6. List and explain in brief: various resources available in android ➢ Layout Resources: o Define the user interface (UI) of an application using XML files. o Stored in the res/layout folder. o Example: activity_main.xml contains UI elements like Buttons, TextViews, etc. ➢ String Resources: o Store text values like app name, messages, and labels to support easy localization. o Stored in the res/values/strings.xml file. ➢ Drawable Resources: o Used for images, shapes, gradients, and other graphics. o Stored in the res/drawable folder. ➢ Color Resources: o Define color values used for UI components like backgrounds and text. o Stored in the res/values/colors.xml file. ➢ Dimension Resources: o Store size values like padding, margin, and text size to maintain consistency. o Stored in res/values/dimens.xml. ➢ Style and Theme Resources: o Define styles and themes to maintain a consistent look and feel across the app. o Stored in res/values/styles.xml. 7. List various Android Intents. Explain any one. ➢ Various Android Intents: o Explicit Intent o Implicit Intent o Broadcast Intent o Pending Intent ➢ Explicit Intent o Explicit Intent is used when we want to start a specific component like an Activity, Service, or BroadcastReceiver inside the same application or another application. o In explicit intent, we clearly specify the target component's class name, so the system knows exactly which component to start. o It is commonly used for navigating between activities in the same app, or starting a specific service. o Example use-case: Moving from a LoginActivity to a DashboardActivity after successful login. o Key Point: Explicit intents are direct and specific because the destination component is clearly mentioned. 8. State the differences between onstart() and onresume(). (C)
1. List various resources in Android. Explain any one.
➢ Various Resources in Android: o Layout Resources o String Resources o Drawable Resources o Color Resources o Dimension Resources o Style and Theme Resources o Menu Resources o Animation Resources ➢ Layout Resource o Layout resource is an XML file used to define the User Interface (UI) of an Android application. o It specifies how UI components like Buttons, TextViews, EditTexts, and Images are arranged on the screen. o Layout resources are stored in the res/layout/ directory of an Android project. o Importance: ▪ UI Design: Helps in designing the visual structure of an app in an organized way. ▪ Separation of UI and Logic: Keeps the UI design separate from Java/Kotlin code, making the app easy to manage and modify. ▪ Supports Multiple Devices: Provides flexible designs that adjust to different screen sizes and orientations (phones, tablets). ▪ Reusability: Layout files can be reused in multiple parts of the application to maintain consistency. 2. Write a short note: Intent filter. ➢ Intent Filter is an important component of Android that declares the capability of an app component (like Activity, Service, or BroadcastReceiver) to handle specific types of intents. ➢ It is defined inside the AndroidManifest.xml file and helps the Android system decide which component should respond to a given intent. ➢ Purpose of Intent Filter: o Handle Implicit Intents: ▪ Intent Filters allow apps to handle implicit intents (intents without specifying a target component). ▪ Example: Opening a webpage, sharing an image, making a call. o App-to-App Communication: ▪ Enables communication between different apps by allowing them to respond to specific actions or data types. o Declare App Capabilities: ▪ Declares what type of actions or data an app component can handle (e.g., viewing an image, opening a URL). ➢ Components of Intent Filter: o Action: Specifies the general action to be performed (e.g., android.intent.action.VIEW). o Data: Specifies the type of data (e.g., http, tel). o Category: Provides additional information about the action to be performed (e.g., android.intent.category.DEFAULT). ➢ Example: 3. What is Intent? Explain various types of Intent. ➢ An Intent in Android is a messaging object used to request an action from another app component (such as Activity, Service, or BroadcastReceiver). ➢ It is used to start a new activity, send data, start a service, or broadcast a message. ➢ Intents are a powerful way to enable communication between components within the same app or between different apps. ➢ Types of Intents: o Explicit Intent: ▪ Used to start a specific component by naming it directly (using class name). ▪ Mostly used to navigate between activities within the same application. ▪ Example: Opening a new activity (e.g., moving from LoginActivity to HomeActivity). o Implicit Intent: ▪ Does not specify a component name. ▪ Used to request an action that can be handled by any app on the device capable of performing that action. ▪ Example: Opening a web page, sending an email, making a call. o Broadcast Intent: ▪ Used to broadcast a message system-wide. ▪ Any app registered to listen for that broadcast can receive it. ▪ Example: Battery low notification, airplane mode change. o Pending Intent: ▪ A special type of intent used to grant permission to another application to execute predefined actions on your app's behalf, even if your app is not running. ▪ Example: Notifications that perform an action when clicked. 4. Explain in detail: Anatomy of Android Application. ➢ An Android application is made up of different components and files that work together to create a functional app. These components are organized in a specific way to ensure smooth operation and user interaction. ➢ This is known as Anatomy of android application. ➢ Components of Android Application Anatomy: o Manifest File: ▪ It is the central file of every Android application. ▪ It declares all app components like Activities, Services, Broadcast Receivers, Content Providers. o Source Code: ▪ Contains Activity, Service, BroadcastReceiver, and other class files written in Java or Kotlin. ▪ These files define the logic and functionality of the app. o Resources (res/ folder): ▪ Stores XML files for UI layouts, images, strings, colors, styles, and more. ▪ Helps in separating design from logic. o Gradle Files: ▪ Used for building and packaging the app. ▪ Specifies dependencies, SDK versions, and build types. ▪ Automates the build process. o Assets Folder: ▪ Contains raw files like HTML, text, audio, or fonts. ▪ These are accessed as raw data. o Native Libraries : ▪ Contains compiled code for specific hardware (like C/C++ libraries). o Application Components: ▪ Activities, Services, Broadcast Receivers, Content Providers 5. What are Resources? Explain various Layout Resources ➢ Resources in Android are external elements like strings, images, colors, layouts, and more, used to design and develop the application. ➢ Resources help in separating the app content and design from the code, making the app flexible, manageable, and adaptable to different devices and languages. ➢ They are stored in the res/ directory of the Android project. ➢ Various Layout Resources in Android: o LinearLayout: ▪ Arranges elements horizontally or vertically in a single row or column. ▪ Example: Placing buttons in a vertical line. o RelativeLayout: ▪ Positions elements relative to each other or to the parent layout. ▪ Example: Placing a button below a text view. o ConstraintLayout: ▪ Allows positioning of UI components by defining constraints relative to other components. ▪ Provides more flexible and complex layouts with better performance. o FrameLayout: ▪ Used to display a single view or stack multiple views on top of each other. ▪ Example: Displaying an image with text overlay. o TableLayout: ▪ Organizes UI components into rows and columns, like a table. ▪ Example: Creating a form layout with labels and input fields. o GridLayout: ▪ Places components in a grid (rows and columns). ▪ Suitable for layouts that require a tabular structure.