0% found this document useful (0 votes)
6 views7 pages

Mad 2

The document outlines the development of a stopwatch Android application, detailing its features, hardware and software requirements, and providing code snippets for the user interface and main functionality. The application includes start, pause, and reset buttons, as well as a display for elapsed time. The project has enhanced the author's skills in Android app development and user interface design.

Uploaded by

gauchavan23
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
6 views7 pages

Mad 2

The document outlines the development of a stopwatch Android application, detailing its features, hardware and software requirements, and providing code snippets for the user interface and main functionality. The application includes start, pause, and reset buttons, as well as a display for elapsed time. The project has enhanced the author's skills in Android app development and user interface design.

Uploaded by

gauchavan23
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 7

➢ Problem Statement

The microproject aims to develop a stopwatch Android application that provides users with a simple tool
for measuring time intervals. The application will include features such as start, stop, and reset buttons,
along with a display area to show the elapsed time. By incorporating a button for starting and stopping the
stopwatch, a reset button for clearing the elapsed time, and a TextView widget to display the current time,
users can easily utilize the stopwatch functionality for various timing needs.

➢ Hardware Requirements
✓ RAM- 16 GB

✓ Processor – Intel Core i5 or higher

✓ Disk space – Minimum 4GB

➢ Software Requirements
✓ Operating system – Windows 10

✓ Android Studio

4
CODE:

<?xml version="1.0" encoding="utf-8"?>


<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:padding="30dp"
android:background="#f5f5f5">

<TextView
android:id="@+id/timer"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="00:00:00"
android:textSize="48sp"
android:textStyle="bold"
android:layout_centerHorizontal="true"
android:layout_marginTop="100dp" />

<Button
android:id="@+id/startButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Start"
android:layout_below="@id/timer"
android:layout_centerHorizontal="true"
android:layout_marginTop="40dp"/>

5
<Button
android:id="@+id/pauseButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Pause"
android:layout_below="@id/startButton"
android:layout_marginTop="20dp"
android:layout_centerHorizontal="true"/>

<Button
android:id="@+id/resetButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Reset"
android:layout_below="@id/pauseButton"
android:layout_marginTop="20dp"
android:layout_centerHorizontal="true"/>
</RelativeLayout>

Main Java Code:


package com.example.stopwatch;
import android.os.Bundle;
import android.os.Handler;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;
import androidx.appcompat.app.AppCompatActivity;

6
public class MainActivity extends AppCompatActivity {

private TextView timerTextView;


private Button startButton, pauseButton, resetButton;

private int seconds = 0;


private boolean running = false;
private boolean wasRunning = false;

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
timerTextView = findViewById(R.id.timer);
startButton = findViewById(R.id.startButton);
pauseButton = findViewById(R.id.pauseButton);
resetButton = findViewById(R.id.resetButton);

runTimer();

startButton.setOnClickListener(v -> running = true);

pauseButton.setOnClickListener(v -> running = false);

resetButton.setOnClickListener(v -> {
running = false;
seconds = 0;

7
});
}

private void runTimer() {


final Handler handler = new Handler();
handler.post(new Runnable() {
@Override
public void run() {
int hrs = seconds / 3600;
int mins = (seconds % 3600) / 60;
int secs = seconds % 60;

String time = String.format("%02d:%02d:%02d", hrs, mins, secs);


timerTextView.setText(time);

if (running) {
seconds++;
}

handler.postDelayed(this, 1000);
}
});
}
}

8
Output

9
Conclusion
the development of the stopwatch Android application has provided valuable insights into creating
interactive user interfaces and implementing functionality in Android Studio. Through this project,
I gained hands-on experience in designing layouts, handling user input, and managing timer
functionality. Special thanks to Prof. A.L. Devkate me through this project and providing an
opportunity to explore and enhance my skills in Android app development. This project not only
allowed me to apply theoretical knowledge but also encouraged creativity and problem-solving
skills. Overall, it has been a rewarding experience, and I look forward to further exploring the
world of mobile app development.

Reference
• www.google.com
• www.javtpoint.com
• www.tutorialspoint.com
• www.wikipedia.com

10

You might also like