Android Development Practical Exam Solutions

1. RecyclerView Features and GridView Implementation

RecyclerView Features:

  • View Recycling: Reuses views to improve performance and reduce memory usage.
  • ViewHolder Pattern: Stores item views to avoid repeated findViewById() calls.
  • Flexible Layout: Supports LinearLayoutManager, GridLayoutManager, and StaggeredGridLayoutManager.

GridView Implementation:

GridView gridView = findViewById(R.id.gridView);
String[] languages = {"C", "C++", "Java", "Python", "Kotlin"};
ArrayAdapter<String> adapter = new ArrayAdapter<>(this, android.R.layout.simple_list_item_1, languages);
gridView.setAdapter(adapter);

2. API Types and Activity Data Passing

Types of API:

  • Open API: Available for developers and public use.
  • Partner API: Shared only with specific business partners.
  • Internal API: Used within an organization.
  • Composite API: Combines multiple APIs in a single request.

Passing Data Between Activities:

First Activity:

Intent i = new Intent(MainActivity.this, SecondActivity.class);
i.putExtra("name", "Ram");
i.putExtra("age", 25);
startActivity(i);

Second Activity:

Intent i = getIntent();
String name = i.getStringExtra("name");
int age = i.getIntExtra("age", 0);

3. SQLite Database Operations

Create Database:

SQLiteDatabase db = openOrCreateDatabase("BookStore", MODE_PRIVATE, null);
db.execSQL("CREATE TABLE IF NOT EXISTS Book(book_id INTEGER, name TEXT, author TEXT)");

Insert Data:

db.execSQL("INSERT INTO Book VALUES(1, 'Java', 'James Gosling')");

Display Data:

Cursor c = db.rawQuery("SELECT * FROM Book", null);
while(c.moveToNext()) {
    String id = c.getString(0);
    String name = c.getString(1);
    String author = c.getString(2);
}

4. Android Fundamentals and Architecture

What is Android? Android is an open-source mobile operating system based on Linux, developed by Google for mobile applications.

Categories of Mobile Devices:

  • Smartphones: Android phones with apps and internet.
  • Tablets: Large screen portable devices.
  • Wearables: Smartwatches and fitness bands.
  • Smart TV: Android-powered television.
  • Embedded devices: Car systems and smart home devices.

Android Architecture:

  • Applications: User-facing apps.
  • Application Framework: Activity Manager, Window Manager.
  • Runtime (ART/DVM): Executes applications.
  • Libraries: SQLite, WebKit.
  • Linux Kernel: Hardware and drivers.

5. Layout Gravity vs. Gravity

layout_gravitygravity
Aligns view in parentAligns content inside view

6. Fragments and Intents

Why Fragments? They are reusable UI components inside an Activity used for flexible UI design.

Implicit Intent Example:

Intent i = new Intent(Intent.ACTION_SEND);
i.putExtra(Intent.EXTRA_TEXT, "Hello");
i.setType("text/plain");
startActivity(i);

7. Menus and JSON

Menu: A list of actions or options provided to the user.

JSON: JavaScript Object Notation is a lightweight data format for exchanging data between client and server.

8. iOS Storyboard and Swift Basics

Storyboard: A visual interface design tool in iOS used to design screens and navigation.

Swift Largest & Smallest of 3 Numbers:

let a=10, b=20, c=5
let largest = a>b ? (a>c ? a : c) : (b>c ? b : c)
let smallest = a<b ? (a<c ? a : c) : (b<c ? b : c)

9. Mobile Platforms and Surface Manager

Mobile Platforms: Android, iOS, Windows Mobile, BlackBerry OS.

Surface Manager Library: Handles display surfaces and screen composition.

10. Activity vs. Fragment

ActivityFragment
Full screen componentPart of activity
IndependentDependent
Has lifecycleLifecycle inside activity

11. Toast and SQLite Data Types

Toast: A small popup message displayed for a short time.

SQLite Types: INTEGER, TEXT, REAL, BLOB, NULL.

12. View Hierarchy and Array Sum

View Hierarchy: Arrangement of UI elements in a parent-child structure.

Swift Array Sum:

let arr = [1, 2, 3, 4]
var sum = 0
for i in arr { sum += i }

13. Mobile Development Approaches

  1. Native apps: Platform-specific (Android/iOS).
  2. Web apps: Run in a browser.
  3. Hybrid apps: Web + native (e.g., Ionic).
  4. Cross-platform apps: Single code for multiple platforms (e.g., Flutter).

14. Android Directory Structure

  • manifests: App configuration.
  • java: Source code.
  • res: Resources (layout, drawable, values, menu).
  • Gradle Scripts: Build configuration.

15. AVD and Spinner

AVD Steps: Android Studio → Tools → AVD Manager → Create Virtual Device.

Spinner Example:

Spinner sp = findViewById(R.id.spinner);
ArrayAdapter adapter = new ArrayAdapter(this, android.R.layout.simple_spinner_item, items);
sp.setAdapter(adapter);

16. Alert Dialog and ListView

Alert Dialog:

AlertDialog.Builder b = new AlertDialog.Builder(this);
b.setTitle("Warning");
b.setMessage("Delete item?");
b.setPositiveButton("Yes", null);
b.show();

17. Remote Database and Google Maps

Google Map API Key Steps: Open Google Cloud Console → Create Project → Enable Maps SDK → Generate API Key.

18. ArrayAdapter vs. CursorAdapter

ArrayAdapterCursorAdapter
Uses array/list dataUses database cursor
Simple dataDatabase data

19. APK Contents

  • classes.dex: Compiled code.
  • AndroidManifest.xml: App metadata.
  • resources/assets: App assets.
  • libraries: Native libraries.