Android and iOS Mobile App Development Solutions

Posted by Anonymous and classified in Computers

Written on in English with a size of 11.74 KB

RecyclerView Features and GridView Implementation

1. List and explain any three features of RecyclerView. Develop an Android application to display any five programming languages in GridView.

  • 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.

Example: XML and Java

Java Code:

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);

API Types and Data Passing Between Activities

2. Explain different types of API. Develop an Android application to pass name and age of customer from one activity to another.

Types of API

  • Open API (Public API): Available for developers and public use.
  • Partner API: Shared only with specific business partners.
  • Internal API (Private 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);

SQLite Database Operations in Android

11. Provided that a SQLite database named “BookStore” with a table named Book with the following columns: book_id (Integer), name (Text), author (Text). Develop an Android application to insert and display records from the database.

Create Database

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

Insert and Display Data

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);
}

Android Fundamentals and Device Categories

1. What is Android? Explain different categories of mobile devices.

Android is an open-source mobile operating system based on Linux, developed by Google, used to develop 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 and Components

2. Explain Android architecture with suitable diagram.

Android Architecture Layers

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

Layout Gravity and Unit Conversion App

3. Difference between android:layout_gravity and android:gravity. Develop KM to Meter app.

Gravity Differences

layout_gravitygravity
Aligns view in parentAligns content inside view

Formula: Meter = KM × 1000

Java Implementation:

double km = Double.parseDouble(e1.getText().toString());
double meter = km * 1000;
result.setText("" + meter);

Fragments and Implicit Intents

4. Why is a fragment needed? Send data using implicit intent.

A fragment is a reusable UI component 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);

Menus and JSON Data Handling

5. What is a menu? Create a popup menu with Edit, Copy, Paste, Redo, Undo.

A menu is a list of actions or options provided to the user.

Java Implementation:

PopupMenu p = new PopupMenu(this, view);
p.inflate(R.menu.menu);
p.show();

6. What is JSON? Display 10 fruit images in GridView.

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

iOS Development and Swift Programming

7. What is a storyboard? Swift program for largest & smallest of 3 numbers.

A storyboard is a visual interface design tool in iOS used to design screens and navigation.

Swift Code

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)
print(largest)
print(smallest)

Mobile Platforms and Runtime Environments

1. What is a Smart Mobile Device? Explain mobile platforms.

A portable device with an OS, internet, and app support. Platforms include Android, iOS, Windows Mobile, and BlackBerry OS.

2. What is Surface Manager Library? Difference between DVM and ART.

The Surface Manager handles display surfaces and screen composition.

DVMART
Dalvik Virtual MachineAndroid Runtime
JIT compilationAOT compilation
SlowerFaster

Layouts, Activities, and Fragments

3. Important attributes in AbsoluteLayout.

Attributes include: android:layout_x, android:layout_y, android:layout_width, and android:layout_height. Used to position widgets at exact coordinates.

Q4. Difference between Activity and Fragment.

ActivityFragment
Full screen componentPart of activity
IndependentDependent
Has lifecycleHas lifecycle inside activity

UI Components and SQLite Data Types

5. What is Toast?

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

Toast.makeText(this, "Hello", Toast.LENGTH_SHORT).show();

6. SQLite Data Types

SQLite supports: INTEGER, TEXT, REAL, BLOB, and NULL.

iOS View Hierarchy and Swift Arrays

7. What is View Hierarchy in iOS? Write a Swift program to find the sum of an array.

View Hierarchy is the arrangement of UI elements in a parent-child structure (e.g., UIView containing UILabel, UIButton, and UIImageView).

Swift Code

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

Mobile Application Development Approaches

1. Mobile Application Development Approaches.

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

Android Directory Structure and AVD

Q2. Android Directory Structure.

The structure includes: app, manifests, java, res (layout, drawable, values, menu), and Gradle Scripts.

Q3. How to create AVD? How to use Spinner?

AVD Steps: Open Android Studio → Tools → AVD Manager → Create Virtual Device → Select device and system image.

Q5. Alert Dialog Example

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

ListView and Custom Dialogs

Develop an Android application to display student names in ListView and show student details in a Custom Dialog.

String[] students = {"Ram", "Shyam", "Hari"};
ArrayAdapter adapter = new ArrayAdapter(this, android.R.layout.simple_list_item_1, students);
listView.setAdapter(adapter);
listView.setOnItemClickListener((parent, view, pos, id) -> {
    AlertDialog.Builder b = new AlertDialog.Builder(this);
    b.setTitle("Student Details");
    b.setMessage("Name: " + students[pos]);
    b.show();
});

Remote Database Connection (MySQL and PHP)

2. Provided MySQL database "Bank" with table Customer. Develop Android app to connect remotely.

PHP Example:

$conn = mysqli_connect("localhost", "root", "", "Bank");
$sql = "SELECT * FROM Customer WHERE amount > 5000";
$result = mysqli_query($conn, $sql);
echo json_encode(mysqli_fetch_all($result));

Google Maps API Integration

3. Explain procedure for generating Google Map API key.

Steps: Open Google Cloud Console → Create project → Enable Maps SDK → Go to Credentials → Generate API Key.

Java Code for Marker

LatLng tu = new LatLng(27.6827, 85.2890);
mMap.addMarker(new MarkerOptions().position(tu).title("Tribhuvan University"));
mMap.moveCamera(CameraUpdateFactory.newLatLng(tu));

Adapters and APK Contents

Q1. Difference between ArrayAdapter and CursorAdapter.

ArrayAdapterCursorAdapter
Uses array/list dataUses database cursor
Simple dataDatabase data

Q3. What does an Android APK file contain?

  • classes.dex: Compiled code.
  • AndroidManifest.xml: App configuration.
  • resources: Layouts and drawables.
  • assets: Raw files.
  • libraries: Native libs.

Remote Content Retrieval and Signed APK

Q2. Develop Android application to retrieve content from remote server.

URL url = new URL("https://example.com/data");
HttpURLConnection con = (HttpURLConnection)url.openConnection();
InputStream in = con.getInputStream();

Q3. How to generate signed APK?

  1. Build → Generate Signed Bundle/APK.
  2. Create keystore.
  3. Select release build.
  4. Generate APK.

Location Code

LocationManager lm = (LocationManager)getSystemService(LOCATION_SERVICE);
Location loc = lm.getLastKnownLocation(LocationManager.GPS_PROVIDER);
double lat = loc.getLatitude();
double lon = loc.getLongitude();

Related entries: