{"id":20511180,"url":"https://github.com/lovoo/lastwords","last_synced_at":"2026-04-21T10:03:03.122Z","repository":{"id":142007194,"uuid":"84586122","full_name":"lovoo/lastwords","owner":"lovoo","description":"lastwords is a little library written solely in Kotlin which notifies you when your app is terminated - that is all activities are either finishing or have been destroyed.","archived":false,"fork":false,"pushed_at":"2018-05-31T12:33:52.000Z","size":138,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":31,"default_branch":"master","last_synced_at":"2025-01-16T09:07:26.097Z","etag":null,"topics":["android","android-library","lifecycle","lovoo"],"latest_commit_sha":null,"homepage":"","language":"Kotlin","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/lovoo.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2017-03-10T17:49:41.000Z","updated_at":"2021-05-20T19:03:19.000Z","dependencies_parsed_at":null,"dependency_job_id":"97f78e47-0398-4716-805b-b2067eb71a49","html_url":"https://github.com/lovoo/lastwords","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lovoo%2Flastwords","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lovoo%2Flastwords/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lovoo%2Flastwords/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lovoo%2Flastwords/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/lovoo","download_url":"https://codeload.github.com/lovoo/lastwords/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":242117660,"owners_count":20074433,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["android","android-library","lifecycle","lovoo"],"created_at":"2024-11-15T20:34:55.787Z","updated_at":"2026-04-21T10:03:03.076Z","avatar_url":"https://github.com/lovoo.png","language":"Kotlin","funding_links":[],"categories":[],"sub_categories":[],"readme":"[![Release](https://jitpack.io/v/lovoo/lastwords.svg)](https://jitpack.io/#lovoo/lastwords)\n\n# lastwords\n_lastwords_ is a little library written purely in Kotlin which notifies you when your app is terminated - that is all activities are either finishing or have been destroyed.\n\n## A short definition of a _finished_ app\nFor _lastwords_ a finished app is an app whose activities are all either _finishing_ or _destroyed_. So yes, we are excluding things like services here.\nThis proved to be a rather flexible definition for most use cases. If you stumble upon a use case which isn't covered by this feel free to create an issue and we'll discuss.\n\n## Import\n_lastwords_ is hosted on JitPack. Therefore you can simply import it by adding\n\n```groovy\nallprojects {\n    repositories {\n        ...\n        maven { url \"https://jitpack.io\" }\n    }\n}\n```\n\nto your projects `build.gradle`.\n\nThen add this to you app's `build.gradle`:\n\n```groovy\ndependencies {\n    compile 'com.github.lovoo:lastwords:1.1.0'\n}\n```\n\n## Usage\nUsing _lastwords_ is very simple. In your Application class add the following initialisation code to the `onCreate()` method:\n\n ```kotlin\noverride fun onCreate() {\n    super.onCreate()\n\n    LastWords.init(this)\n}\n ```\n\nIn case you don't have an own subclass of the Application class yet, kindly refer to the documentation of [Application](https://developer.android.com/reference/android/app/Application.html).\n\nWhenever you want to be notified of the app finishing just register a listener:\n\n```kotlin\nLastWords.register(object : LastWords.Listener {\n    override fun onAppFinished() {\n        // do whatever you want here: tracking, cleaning up, herding llamas...\n        Toast.makeText(this@Application, \"App finished\", Toast.LENGTH_SHORT).show()\n    }\n})\n```\nOf course you can register as many listeners as you want.\n\nTo stop listening use `LastWords.unregister(listener)` - you don't want to create nasty memory leaks, do you?\n\nIf you want to kill your app process with _lastwords_ you can use:\n\n ```kotlin\nLastWords.finishApp(killDelay)\n ```\n This will finish all Activities, then wait for the given delay and kill your process (if no other Activity is started in the meantime).\n An example would be to notify the user that changes took place after App restart and you show him an option to close the app.\n But do NOT call this if you have running tasks, like Database or Filesystem writing!!!\n\nAnd that's it. Keep in mind that the system may kill the app process at any point in time (especially as it is effectively backgrounded now), so it's not _guaranteed_ that the code in the listener is executed - but what is guaranteed on our beloved Android anyway? ;)\nHowever it will run happily in the overwhelming majority of cases which usually is better than not executing the code at all - that means it is definitely good for clean up tasks, tracking.","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flovoo%2Flastwords","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Flovoo%2Flastwords","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flovoo%2Flastwords/lists"}