GOVERNMENT POLYTECHNIC, ARVI
DEPARTMENT OF COMPUTER ENGINEERING
Class Test: I (EVEN TERM 2024-25)
Model Solution & Marking Scheme
Course Code &Title: 22617 & MOBILE APPLICATION DEVELOPMENT
Q1. Attempt any Four Marking
Scheme
a. State android ECO system. 2 Marks
Ans. Android Ecosystem consists of Each
1. Google and OHA members: Develops android for devices Component:
2. Original Equipment Manufacturers (OEM): Smartphone, tablet, Android TV ½ Mark
manufacturers
3. Application Development Companies: Develops number of Android apps
4. Freelance Android Application developers: Contribute individually by publishing
their own android application
b Define Android Virtual Device (AVD). 2 Marks
Ans. Android Virtual Device (AVD), which represents a specific Android device. We can Definition:
use the Android emulator as a target device to execute and test our Android application 2 Marks
on our PC. The Android emulator provides almost all the functionality of a real device.
We can get the incoming phone calls and text messages. It also gives the location of
the device and simulates different network speeds. Android emulator simulates rotation
and other hardware sensors. It accesses the Google Play store, and much more.
c List all tools and software’s required for developing an android application. 2 Marks
Ans. 1. Java Development kit (JDK) Each Tool:
2. Android SDK ½ Mark
3. Development Environment (Android Studio,
Eclipse(depreciated))
d Write the directory path where images are stored while developing AndroidApp. 2 Marks
Ans. res/drawable: we store the various density-independent graphic assets used in our
application. It contains many sub-directories.
sub-directories: drawable-hdpi, drawable-ldpi, drawable-mdpi, drawable-xhdpi
e Give the use of AndroidManifest.xml and build.gradle file. 2 Marks
Ans. 1 mark each
AndroidManifest.xml: it defines the structure and metadata of our application, its
components, and its requirements. This file includes nodes for each of the Activities,
Services, Content Providers and Broadcast Receiver that make the application and
using Intent Filters and Permissions, determines how they co-ordinate with each other
and other applications.
build.gradle file: This defines the module-specific build configurations. Here youcan
add dependencies what you need in your Android application.
Q 2. Attempt any THREE
a. Describe the Android architecture in detail. 4 Marks
Ans. android architecture is categorized into five parts: Diagram
i.linux kernel :2 Marks
ii.native libraries (middleware), Explainatio
iii.Android Runtime n: 2 Marks
iv.Application Framework
v.Applications
1) Linux kernel
It is the heart of android architecture that exists at the root of android architecture.
Linux kernel is responsible for device drivers, power management, memory
management, device management and resource access.
2) Native Libraries
On the top of linux kernel, there are Native libraries such as WebKit, OpenGL,
FreeType, SQLite, Media, C runtime library (libc) etc. The WebKit library is
responsible for browser support, SQLite is for database, FreeType for font support,
Media for playing and recording audio and video formats.
3) Android Runtime
In android runtime, there are core libraries and DVM (Dalvik Virtual Machine) which
is responsible to run android application. DVM is like JVM but it is optimized for
mobile devices. It consumes less memory and provides fast performance.
4) Android Framework
On the top of Native libraries and android runtime, there is android framework.
Android framework includes Android API's such as UI (User Interface), telephony,
resources, locations, Content Providers (data) and package managers. It provides a lot
of classes and interfaces for android application development.
5) Applications
On the top of android framework, there are applications. All applications such as home,
contact, settings, games, browsers are using android framework that uses android
runtime and libraries. Android runtime and native libraries are using linux kernal.
b. Design a user interface using a table layout to display buttons for numbers 0 to 4 Marks
9, along with submit and clear buttons. When a user clicks on the number
buttons and then clicks the submit button, the clicked numbers should be
displayed.
Ans. activity_main.xml activity_mai
<?xml version="1.0" encoding="utf-8"?> n.xml: 2
<androidx.constraintlayout.widget.ConstraintLayout Marks
xmlns:android="http://schemas.android.com/apk/res/android" &
android:layout_width="match_parent" MainActivit
android:layout_height="match_parent"> y.java
<!-- Number Grid --> : 2Marks
<GridLayout
android:id="@+id/gridLayout"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:columnCount="3"
android:rowCount="4"
android:layout_centerInParent="true"
android:gravity="center">
<!-- Number Buttons -->
<Button
android:id="@+id/button1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="1"
android:textSize="24sp" />
<Button
android:id="@+id/button2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="2"
android:textSize="24sp" />
<Button
android:id="@+id/button3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="3"
android:textSize="24sp" />
<Button
android:id="@+id/button4"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="4"
android:textSize="24sp" />
<Button
android:id="@+id/button5"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="5"
android:textSize="24sp" />
<Button
android:id="@+id/button6"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="6"
android:textSize="24sp" />
<Button
android:id="@+id/button7"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="7"
android:textSize="24sp" />
<Button
android:id="@+id/button8"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="8"
android:textSize="24sp" />
<Button
android:id="@+id/button9"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="9"
android:textSize="24sp" />
<!-- Number 0 Button -->
<Button
android:id="@+id/button0"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="0"
android:textSize="24sp" />
<!-- Clear and Submit Buttons -->
<Button
android:id="@+id/buttonClear"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Clear"
android:textSize="20sp" />
<Button
android:id="@+id/buttonSubmit"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Submit"
android:textSize="20sp" />
</GridLayout>
<!-- Output Text -->
<TextView
android:id="@+id/outputText"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text=""
android:textSize="24sp"
android:layout_marginTop="20dp"
android:gravity="center"
android:layout_below="@+id/gridLayout"
android:layout_centerHorizontal="true"/>
</androidx.constraintlayout.widget.ConstraintLayout>
MainActivity.java
package com.example.numberpad;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;
import androidx.appcompat.app.AppCompatActivity;
public class MainActivity extends AppCompatActivity {
private TextView outputText;
private StringBuilder currentInput;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
outputText = findViewById(R.id.outputText);
currentInput = new StringBuilder();
// Number buttons (0-9)
int[] numberButtonIds = new int[] {
R.id.button0, R.id.button1, R.id.button2, R.id.button3, R.id.button4,
R.id.button5, R.id.button6, R.id.button7, R.id.button8, R.id.button9
};
// Attach click listeners to each number button
for (int id : numberButtonIds) {
Button numberButton = findViewById(id);
numberButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Button clickedButton = (Button) v;
currentInput.append(clickedButton.getText().toString());
outputText.setText(currentInput.toString());
}
});
}
// Clear button functionality
Button clearButton = findViewById(R.id.buttonClear);
clearButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
currentInput.setLength(0); // Clears the input string
outputText.setText("");
}
});
// Submit button functionality
Button submitButton = findViewById(R.id.buttonSubmit);
submitButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
String input = currentInput.toString();
if (!input.isEmpty()) {
// For now, display the input in the TextView
outputText.setText("Submitted: " + input);
}
}
});
}
}
c. Differentiate between JVM and DVM. 4 Marks
Ans. Each
difference:
1 Mark
d. Explain attributes of Relative layout. 4 Marks
Ans. 1. android:layout_width and android:layout_height: Each
These attributes define the size of the RelativeLayout. Common values are Attribute
match_parent, wrap_content, or fixed sizes (e.g., 200dp). with
example:
match_parent: The RelativeLayout will expand to fill the available space in the parent
1Mark
container.
wrap_content: The RelativeLayout will wrap its content based on the size of its child
views.
2. android:layout_alignParentLeft / android:layout_alignParentStart:
Aligns the child view to the left (or start) of the parent RelativeLayout.
Example:
android:layout_alignParentStart="true" <!-- Aligns the view to the left side -->
3. android:layout_alignParentTop:
Aligns the child view to the top of the parent container.
Example:
android:layout_alignParentTop="true" <!-- Aligns the view to the top -->
4. android:layout_alignParentRight / android:layout_alignParentEnd:
Aligns the child view to the right (or end) of the parent RelativeLayout.
Example:
android:layout_alignParentEnd="true" <!-- Aligns the view to the right side -->
5. android:layout_alignParentBottom:
Aligns the child view to the bottom of the parent container.
Example:
android:layout_alignParentBottom="true" <!-- Aligns the view to the bottom -->
6. android:layout_centerInParent:
Centers the child view both horizontally and vertically within the parent
RelativeLayout.
Example:
android:layout_centerInParent="true" <!-- Centers the view in the parent -->
7. android:layout_centerHorizontal:
Centers the child view horizontally within the parent RelativeLayout.
Example:
android:layout_centerHorizontal="true" <!-- Centers the view horizontally -->
8. android:layout_centerVertical:
Centers the child view vertically within the parent RelativeLayout.
Example:
android:layout_centerVertical="true" <!-- Centers the view vertically -->
9. android:layout_toLeftOf / android:layout_toStartOf:
Positions the child view to the left (or start) of another view.
Example:
android:layout_toStartOf="@id/otherView" <!-- Places the view to the left of
another view -->
10. android:layout_toRightOf / android:layout_toEndOf:
Positions the child view to the right (or end) of another view.
Example:
android:layout_toEndOf="@id/otherView" <!-- Places the view to the right of
another view -->
11. android:layout_below:
Positions the child view below another specified view.
Example:
android:layout_below="@id/otherView" <!-- Places the view below another view --
>
12. android:layout_above:
Positions the child view above another specified view.
Example:
android:layout_above="@id/otherView" <!-- Places the view above another view -->
13.android:layout_alignWithParentIfMissing:
This attribute can be set to true to force the view to align with the parent if no other
positioning attributes (like layout_below) are defined. This is often used to handle
missing alignments gracefully.
14. android:layout_margin:
Specifies the margin between the view and its neighboring elements.
Example:
android:layout_margin="16dp" <!-- Sets a margin around the view -->
15. android:layout_marginTop, android:layout_marginLeft,
android:layout_marginBottom, android:layout_marginRight:
These are specific margin attributes that allow you to set margins on specific sides of
the view.