GithubHelp home page GithubHelp logo

justamalll / stopwatch Goto Github PK

View Code? Open in Web Editor NEW
15.0 1.0 0.0 111 KB

Stopwatch Application with Jetpack Compose!

Kotlin 100.00%
android android-services bound-service dagger-hilt dagger2 dependency-injection foreground-service jetpack-compose kotlin animations

stopwatch's Introduction

Stopwatch - Android App with Jetpack Compose

A simple stopwatch application with jetpack compose using foreground and bound services

This application basically consists of 3 different text units representing Hours, Minutes and Seconds. Also we got two buttons on the UI. The first button will be changed on the basis of service state and the second button will allow us to cancel the foreground service which will result in resetting of our stopwatch.

You can control the stopwatch either by the UI buttons or with the notification panel. As we are using services, so if we even close the application then also we can track the stopwatch state by notification panel.

This project uses:

  • Dagger-Hilt
  • Bound Service
  • Foreground Service

Dagger-Hilt

Hilt is a dependency injection library for Android that reduces the boilerplate of doing manual dependency injection in your project. Doing manual dependency injection requires you to construct every class and its dependencies by hand, and to use containers to reuse and manage dependencies.

Hilt provides a standard way to use DI in your application by providing containers for every Android class in your project and managing their lifecycles automatically. Hilt is built on top of the popular DI library Dagger to benefit from the compile-time correctness, runtime performance, scalability, and Android Studio support that Dagger provides.

Bound Service

A bound service is an implementation of the Service class that allows other applications to bind to it and interact with it. To provide binding for a service, you must implement the onBind() callback method. This method returns an IBinder object that defines the programming interface that clients can use to interact with the service.

Foreground Service

Foreground services perform operations that are noticeable to the user.

Foreground services show a status bar notification, so that users are actively aware that your app is performing a task in the foreground and is consuming system resources.

Devices that run Android 12 (API level 31) or higher provide a streamlined experience for short-running foreground services. On these devices, the system waits 10 seconds before showing the notification associated with a foreground service. There are a few exceptions; several types of services always display a notification immediately.

stopwatch's People

Contributors

justamalll avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

stopwatch's Issues

Application leak

LeakCanary log:

HEAP ANALYSIS RESULT
====================================
1 APPLICATION LEAKS

References underlined with "~~~" are likely causes.
Learn more at https://squ.re/leaks.

4271 bytes retained by leaking objects
Signature: e5a9939bbcf81f0b7f03f20bbc2ce24fba97a2db
┬───
│ GC Root: Global variable in native code
│
├─ dev.amal.stopwatch.service.StopwatchService$StopwatchBinder instance
│    Leaking: UNKNOWN
│    Retaining 4.8 kB in 78 objects
│    this$0 instance of dev.amal.stopwatch.service.StopwatchService
│    ↓ StopwatchService$StopwatchBinder.this$0
│                                       ~~~~~~
╰→ dev.amal.stopwatch.service.StopwatchService instance
​     Leaking: YES (ObjectWatcher was watching this because dev.amal.stopwatch.service.StopwatchService received
​     Service#onDestroy() callback and Service not held by ActivityThread)
​     Retaining 4.3 kB in 77 objects
​     key = e882fce8-cacf-405a-8eb1-5449f4ec4b7b
​     watchDurationMillis = 13920
​     retainedDurationMillis = 8919
​     mApplication instance of dev.amal.stopwatch.StopwatchApplication
​     mBase instance of android.app.ContextImpl
====================================
0 LIBRARY LEAKS

A Library Leak is a leak caused by a known bug in 3rd party code that you do not have control over.
See https://square.github.io/leakcanary/fundamentals-how-leakcanary-works/#4-categorizing-leaks
====================================
0 UNREACHABLE OBJECTS

An unreachable object is still in memory but LeakCanary could not find a strong reference path
from GC roots.
====================================
METADATA

Please include this in bug reports and Stack Overflow questions.

Build.VERSION.SDK_INT: 34
Build.MANUFACTURER: Xiaomi
LeakCanary version: 2.14
App process name: dev.amal.stopwatch
Class count: 29636
Instance count: 188984
Primitive array count: 146503
Object array count: 26557
Thread count: 20
Heap total bytes: 27893793
Bitmap count: 0
Bitmap total bytes: 0
Large bitmap count: 0
Large bitmap total bytes: 0
Stats: LruCache[maxSize=3000,hits=112988,misses=180110,hitRate=38%]
RandomAccess[bytes=9102417,reads=180110,travel=59051795609,range=33440756,size=42079108]
Heap dump reason: 1 retained objects, app is not visible
Analysis duration: 16898 ms
Heap dump file path: /storage/emulated/0/Download/leakcanary-dev.amal.stopwatch/2024-06-14_22-07-48_531.hprof
Heap dump timestamp: 1718395690773
Heap dump duration: 2535 ms
====================================

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.