IT3681 Mobile Applications Development Laboratory
IT3681 Mobile Applications Development Laboratory
LIST OF EXPERIMENTS
TOTAL: 45 PERIODS
Ex No : 1
Study and installation of Flutter/Kotlin multi-platform
Date: environment
Aim:
Procedure:
Flutter:
You can use Android Studio, IntelliJ IDEA, or Visual Studio Code for Flutter development.
Install the Flutter and Dart plugins for your chosen IDE.
Open a terminal and run flutter doctor to check for any dependencies that need to be
installed. Follow the instructions provided by flutter doctor to resolve any issues.
Kotlin:
Install Kotlin:
You can install Kotlin by following the instructions on the official Kotlin website.
Set up an IDE:
Kotlin Multiplatform projects are well-supported in IntelliJ IDEA. Install the Kotlin plugin
for your IDE.
Prelab Questions:
Postlab Questions:
1. What were the main challenges you encountered during the installation process, and
how did you overcome them?
2. Reflect on the integration of Flutter and Kotlin Multiplatform. In what ways did this
combination enhance or complicate the development workflow?
3. Discuss any insights gained from the process of sharing code between Flutter and Kotlin
Multiplatform. Were there any unexpected benefits or challenges?
4. Consider the testing phase. How did the multi-platform nature of the project impact
testing strategies, and what adjustments were made to ensure thorough testing across
platforms?
5. Evaluate the overall development experience with Flutter and Kotlin Multiplatform.
What aspects would you highlight as strengths, and are there areas that could be
improved in future projects?
Results:
Thus the Study and installation of Flutter/Kotlin multi-platform environment has been
executed successfully.
Ex No:2
Develop an application that uses Widgets, GUI components, Fonts, and Colors.
Date:
Aim:
Develop an application that uses Widgets, GUI components, Fonts, and Colors.
Procedure:
Program:
import javafx.application.Application
import javafx.geometry.Insets
import javafx.scene.Scene
import javafx.scene.control.Button
import javafx.scene.control.ComboBox
import javafx.scene.control.Label
import javafx.scene.control.TextField
import javafx.scene.layout.VBox
import javafx.scene.text.Font
import javafx.stage.Stage
10
root.padding = Insets(10.0)
// Create a label
label.font = customFont
root.children.add(label)
// Create a button
button.font = customFont
button.setOnAction { onButtonClick() }
root.children.add(button)
textField.font = customFont
root.children.add(textField)
comboBox.items.addAll(comboBoxValues)
11
12
comboBox.font = customFont
root.children.add(comboBox)
primaryStage.scene = scene
primaryStage.show()
println("Button Clicked!")
fun main() {
Application.launch(MyApp::class.java)
13
14
Prelab Questions:
Postlab Questions:
1. Provide a code snippet showcasing the implementation of a button widget in your GUI
application.
2. Mention one widget in your application and describe how you applied color and font
customization to it.
3. Give an example of a user interaction event in your GUI application and how it triggers a
response.
4. Briefly mention one challenge you faced during development and how you addressed it.
5. Suggest one potential improvement for your GUI application in terms of features or user
interface enhancements.
Results:
Thus the application that uses Widgets, GUI components, Fonts, and Colors has been executed
successfully.
15
16
Ex No: 3
Develop a native calculator application.
Date:
Aim:
Procedure:
Open res/layout/activity_main.xml and replace its content with the following Xml code
Open MainActivity.kt and replace its content with the following kotlin code
Program:
Xml:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity">
<EditText
android:id="@+id/inputText"
17
18
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="16dp"
android:layout_marginBottom="16dp"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:hint="Enter expression"
android:inputType="none"
android:textAlignment="center" />
<GridLayout
android:id="@+id/gridLayout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@id/inputText"
android:layout_marginTop="16dp"
android:columnCount="4"
android:orientation="horizontal">
</GridLayout>
</RelativeLayout>
Kotlin:
import android.os.Bundle
import android.view.View
import android.widget.Button
import android.widget.EditText
import androidx.appcompat.app.AppCompatActivity
19
20
import net.objecthunter.exp4j.ExpressionBuilder
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_main)
inputText = findViewById(R.id.inputText)
button.setOnClickListener { onButtonClick(it) }
when (view.id) {
21
22
try {
inputText.setText(result.toString())
inputText.setText("Error")
return
} inputText.setText("$currentText.")
var lastOperatorIndex = -1
lastOperatorIndex = index
} return lastOperatorIndex
23
24
Prelab Questions:
Postlab Questions:
Results:
Thus the program to develop a native calculator application has been executed successfully.
25
26
Ex No: 4
Develop a gaming application that uses 2-D animations and gestures.
Date:
Aim:
Procedure:
Program:
import com.badlogic.gdx.ApplicationAdapter
import com.badlogic.gdx.Gdx
import com.badlogic.gdx.graphics.GL20
import com.badlogic.gdx.graphics.Texture
import com.badlogic.gdx.graphics.g2d.SpriteBatch
27
28
batch = SpriteBatch()
Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT)
batch.begin()
batch.end()
batch.dispose()
img.dispose()
Gesture Recognition:
import com.badlogic.gdx.Gdx
import com.badlogic.gdx.InputProcessor
override fun touchDown(screenX: Int, screenY: Int, pointer: Int, button: Int): Boolean {
return true
return false
29
30
override fun touchUp(screenX: Int, screenY: Int, pointer: Int, button: Int) {}
To use this input processor in your main game class, add the following code in the
create method:
Gdx.input.inputProcessor = inputProcessor
31
32
Prelab Questions:
Postlab Questions:
Results:
Thus the program to develop a gaming application that uses 2-D animations and gestures has
been executed successfully.
33
34
Ex No: 5
Develop a movie rating application (similar to IMDB)
Date:
Aim:
Procedure:
Program:
data class Movie(val title: String, val genre: String, val releaseYear: Int)
data class Rating(val user: String, val movie: String, val rating: Double)
class MovieRatingSystem {
35
36
movies.add(movie)
if (movie != null) {
ratings.add(userRating)
} else {
return if (movieRatings.isNotEmpty()) {
totalRating / movieRatings.size
} else {
0.0
fun listMovies() {
movies.forEach {
37
38
fun main() {
// Adding movies
// Listing movies
println("Available Movies:")
movieRatingSystem.listMovies()
// Rating movies
39
40
Prelab Questions:
1. Which entities are crucial for storing movie information in the database?
2. How will user authentication be handled for secure access?
3. What method will be used to calculate average movie ratings?
4. Which front-end technology will be used for the user interface?
5. What approach will be taken to implement search functionality?
Postlab Questions:
Results:
Thus the program to develop a movie rating application (similar to IMDB) has been executed
successfully.
41
42
Ex No: 6
Develop an application to connect to a web service and to retrieve data with HTTP.
Date:
Aim:
To develop an application to connect to a web service and to retrieve data with HTTP.
Procedure:
1) Use your preferred IDE (such as IntelliJ IDEA) or a build tool (such as Gradle) to create a
new Kotlin project.
2) If you're using Gradle, add the following dependencies to your build.gradle.kts (for
Kotlin DSL) or build.gradle (for Groovy DSL):
implementation "io.ktor:ktor-client-apache:$ktor_version"
implementation "io.ktor:ktor-client-core:$ktor_version"
implementation "io.ktor:ktor-client-serialization:$ktor_version"
3) Make sure to replace $ktor_version with the version of Ktor you want to use.
4) In your project, create a Kotlin file (e.g., Main.kt) to write your application code.
5) Write the code in 'Main.kt'
6) Use your IDE or build tool to run the Kotlin application. The program will make a GET
request to the specified API URL, retrieve data, and print it to the console.
Program:
Main.kt
import io.ktor.client.HttpClient
import io.ktor.client.engine.apache.Apache
import io.ktor.client.request.get
return try {
response
} finally {
client.close()
43
44
fun main() {
try {
println("Error: ${e.message}")
45
46
Prelab Questions:
1. Have you installed the Kotlin plugin and configured your IDE for Kotlin development?
2. Do you know the API endpoint and data format of the web service?
3. Are you familiar with Ktor for making HTTP requests in Kotlin?
4. Have you considered potential exceptions during HTTP requests, and how will you
handle them?
5. If required, how are you handling authentication for the web service?
Postlab Questions:
Results:
Thus the program to develop an application to connect to a web service and to retrieve data
with HTTP has been executed successfully.
47
48
Ex No: 7
Develop a simple shopping application.
Date:
Aim:
Procedure:
Program:
import java.util.Scanner
data class Product(val id: Int, val name: String, val price: Double)
println("\nAvailable Products:")
cart.add(product)
if (cart.isEmpty()) {
} else {
49
50
println("Your Cart:")
println("Total: $$totalPrice")
fun main() {
while (true) {
println("\nMenu:")
println("4. Exit")
when (scanner.nextInt()) {
1 -> {
51
52
displayProducts(products)
2 -> {
if (selectedProduct != null) {
addToCart(cart, selectedProduct)
} else {
3 -> {
viewCart(cart)
4 -> {
return
else -> {
53
54
Prelab Questions:
Postlab Questions:
Results:
Thus the program to develop a simple shopping application has been executed successfully.
55
56
Ex No: 8
Design a web server supporting push notifications.
Date:
Aim:
Procedure:
1) Create a new Kotlin project: Use your preferred IDE or build tool to create a new Kotlin
project.
2) Add Ktor Dependencies: Open your build.gradle.kts (or build.gradle) file and include the
following dependencies for Ktor:
plugins {
repositories {
mavenCentral()
dependencies {
implementation("io.ktor:ktor-server-netty:1.6.10")
implementation("io.ktor:ktor-websockets:1.6.10")
1) Write Ktor Application Code: Create a new Kotlin file (e.g., PushNotificationServer.kt)
and write the Ktor application code:
2) Execute the main function in your PushNotificationServer.kt file. This will start the Ktor
server on http://localhost:8080.
3) Create an HTML file (e.g., index.html) with a simple WebSocket client: Open the
index.html file in a web browser. You can open multiple instances in different tabs or
browsers to simulate multiple clients.
4) Interact with the WebSocket: Type a message in one client and click "Send Message."
You should see the message pushed to all other connected clients in real-time.
57
58
Program:
Kotlin:
import io.ktor.application.*
import io.ktor.features.ContentNegotiation
import io.ktor.features.StatusPages
import io.ktor.http.HttpStatusCode
import io.ktor.jackson.jackson
import io.ktor.routing.routing
import io.ktor.server.engine.embeddedServer
import io.ktor.server.netty.Netty
import io.ktor.websocket.WebSockets
import io.ktor.websocket.webSocket
import kotlinx.coroutines.channels.ClosedReceiveChannelException
import kotlinx.coroutines.channels.consumeEach
import java.time.Duration
fun Application.module() {
install(ContentNegotiation) {
jackson { }
install(StatusPages) {
install(WebSockets) {
pingPeriod = Duration.ofSeconds(60)
59
60
timeout = Duration.ofSeconds(15)
maxFrameSize = Long.MAX_VALUE
masking = false
routing {
webSocket("/push") {
connections.add(this)
try {
if (frame is Frame.Text) {
connections.forEach {
if (it != this) {
it.send(Frame.Text(message))
} finally {
connections.remove(this)
61
62
fun main() {
HTML file:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
</head>
<body>
<ul id="messages"></ul>
<script>
const li = document.createElement("li");
li.appendChild(document.createTextNode(event.data));
messages.appendChild(li);
};
63
64
function sendMessage() {
socket.send(message);
input.value = "";
</script>
</body>
</html>
65
66
Prelab Questions:
Postlab Questions:
Results:
Thus the program to design a web server supporting push notifications has been executed
successfully.
67
68
Ex No: 9
Develop an application by integrating Google maps
Date:
Aim:
Procedure:
To integrate Google Maps into an Android application using Kotlin, you can follow these steps:
Open your app-level build.gradle file and add the Google Maps dependency:
gradle
implementation 'com.google.android.gms:play-services-maps:17.0.1'
Add Permissions:
Make sure you have the necessary permissions in your AndroidManifest.xml file:
xml
Xml
<application>
69
70
<meta-data
android:name="com.google.android.geo.API_KEY"
android:value="YOUR_API_KEY" />
</application>
Xml
<fragment
android:id="@+id/mapFragment"
android:name="com.google.android.gms.maps.SupportMapFragment"
android:layout_width="match_parent"
android:layout_height="match_parent" />
Initialize GoogleMap:
kotlin
import com.google.android.gms.maps.GoogleMap
import com.google.android.gms.maps.OnMapReadyCallback
import com.google.android.gms.maps.SupportMapFragment
super.onViewCreated(view, savedInstanceState)
mapFragment.getMapAsync(this)
71
72
googleMap = map
Run your application on an emulator or a physical device to see the Google Map in action.
73
74
Prelab Questions:
1. Why do you need an API key for integrating Google Maps into your Android application?
2. What is the purpose of adding com.google.android.gms:play-services-maps to your
project's dependencies?
3. Why are location-related permissions (ACCESS_FINE_LOCATION and
ACCESS_COARSE_LOCATION) essential in the AndroidManifest.xml file?
4. How does the SupportMapFragment contribute to the incorporation of Google Maps in
your Android app?
5. Where should you specify the Google Maps API key in the AndroidManifest.xml file?
Postlab Questions:
1. In which callback method do you initialize the GoogleMap object, and why is this crucial
for map-related operations?
2. What steps are involved in adding a marker to the Google Map, and what details can be
associated with a marker?
3. What is the purpose of the CameraUpdateFactory.newLatLngZoom method, and how
does it affect the camera position on the map?
4. Name two common customizations you can apply to the Google Map to enhance the
user experience.
5. What aspects should you focus on when testing your Google Maps integration, and why
is testing important?
Results:
Thus the program to develop an application by integrating Google maps has been executed
successfully.
75
76
Ex No: 10
Mini Projects involving Flutter/Kotlin multi-platform
Date:
Aim:
77
78
79
80
81
82