AndroidPYQ
AndroidPYQ
A native app is a software application built specifically for a particular platform or operating
system (e.g., Android or iOS) using platform-specific programming languages, tools, and
frameworks.
Native apps are downloaded and installed from app stores like Google Play or Apple App
Store, and they leverage the device’s hardware and software features efficiently.
1. Performance:
o Native apps are faster and more efficient as they are optimized for the specific
platform.
2. Access to Device Features:
o They can directly access hardware features like the camera, GPS, microphone,
etc.
3. User Experience:
o Native apps follow the platform's UI/UX design guidelines, ensuring a
seamless user experience.
4. Offline Functionality:
o They can work offline or with limited internet connectivity.
5. Security:
o Native apps are more secure because they use platform-specific security
features.
Toggle buttons are used to enable or disable a specific functionality or to switch between
two states. They represent an on/off or selected/unselected condition, and the user can toggle
between these states by clicking or tapping the button.
Definition of Switch
A switch is a user interface element that allows users to toggle between two mutually
exclusive states, such as ON and OFF, or Enabled and Disabled. It visually resembles a
physical toggle switch and is commonly used in settings to activate or deactivate a specific
feature or functionality.
Q3- How do you find memory leaks in the mobile app on the
Android
Platform ?
Memory leaks happen when your app keeps holding onto objects (like
Activities or Views) that are no longer needed. This wastes memory and
can slow down or crash your app. Here's how you can find and fix them:
Key Tools:
A Toast is a small, temporary message that appears at the bottom of the screen (or a custom
position) to provide feedback or information to the user. It doesn’t block user interaction and
disappears automatically after a short time.
Features of Toast:
Basic Syntax:
Toast is best for short, non-critical messages like "Message sent" or "File
downloaded."
Avoid overusing toasts, as too many can overwhelm or annoy users.
For long-term or interactive notifications, use a Snackbar or Dialog instead.
1. Offline Support: Stores data locally, ideal for offline use cases.
2. Fast and Efficient: Provides fast read/write operations.
3. No Server Required: Everything runs locally on the device.
4. Small Footprint: Optimized for mobile devices.
Example Use Cases
Architecture of Android
This is the topmost layer where all Android apps reside (both system and user-
installed apps).
Examples: Messaging, Contacts, Camera, etc.
Apps are written in Java, Kotlin, or other supported languages and run in the Android
runtime environment.
Built using C and C++, these libraries support high-performance features and
functionalities.
Examples:
o Surface Manager: Manages display and graphics.
o OpenGL ES: Supports 2D and 3D rendering.
o WebKit: Manages web browsing.
o SQLite: Database engine.
o Media Framework: Supports audio and video playback.
markdown
Copy code
-------------------------------------------------------
| Applications |
| (System apps like Contacts, Messaging, User Apps) |
-------------------------------------------------------
| Application Framework |
| (Activity Manager, Window Manager, etc.) |
-------------------------------------------------------
| Android Runtime (ART) and Libraries |
| (Core Libraries, SQLite, OpenGL, etc.) |
-------------------------------------------------------
| Native C/C++/JAVA Libraries |
| (WebKit, Media Framework, Surface Manager, etc.) |
-------------------------------------------------------
| Linux Kernel |
| (Device Drivers, Memory Management, Power, etc.) |
-------------------------------------------------------
Explanation of Interaction
1. Modularity: Different layers allow easy upgrades and replacements without affecting
other parts.
2. Reusability: Core functionalities (like SQLite) can be reused across apps.
3. Security: The architecture ensures better isolation and security for apps and data.
1. Foreground Service:
o Runs in the foreground and requires a notification to indicate that it is running.
o Example: Music player showing a notification for playback controls.
2. Background Service:
o Runs in the background without user interaction.
o Example: Syncing data to a server.
o Since Android 8.0 (Oreo), restrictions have been placed on background
services.
3. Bound Service:
o Binds an activity or other component to the service for interaction.
o Example: Apps communicating with a server via a bound service.
i) AutoCompleteTextView in Android
Features:
EditText is a user interface element in Android used for text input. It allows users to enter
and modify text through the device's keyboard. It is the most commonly used widget for
gathering user input such as names, emails, passwords, etc.
Features:
Text Input: Supports different types of text input, such as plain text, passwords,
numbers, etc.
Customizable: You can customize the input behavior using input types, filters, and
other attributes.
Focusable: It is focusable, meaning the user can interact with it, and it can bring up
the keyboard for text input.
Editable: Users can edit the content inside the EditText field.
Key Features:
What is an Interface?
An interface is a reference type in Java, similar to a class, that can contain only abstract
methods (methods without implementation) and constants (fields that are static and final).
Interfaces are used to represent a contract or capability that can be implemented by any class,
regardless of the class hierarchy.
Key Features:
1. Abstract Methods Only: All methods in an interface are implicitly abstract (though
from Java 8 onward, default and static methods with implementation are allowed).
2. Multiple Inheritance: A class can implement multiple interfaces, enabling multiple
inheritance of type.
3. No Constructors or State: Interfaces cannot have constructors or member variables,
except for static final constants.