{"id":13610112,"url":"https://github.com/int02h/primaree","last_synced_at":"2025-05-13T02:21:41.873Z","repository":{"id":44923086,"uuid":"249791792","full_name":"int02h/primaree","owner":"int02h","description":"A simple library for safe initialization of multi-process Android applications","archived":false,"fork":false,"pushed_at":"2023-07-13T12:07:19.000Z","size":152,"stargazers_count":72,"open_issues_count":1,"forks_count":1,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-04-01T05:55:44.947Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Kotlin","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/int02h.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":"2020-03-24T18:51:59.000Z","updated_at":"2025-03-21T12:11:35.000Z","dependencies_parsed_at":"2024-08-01T19:43:53.463Z","dependency_job_id":"b1331224-625f-48ae-8002-823ccbbfd81d","html_url":"https://github.com/int02h/primaree","commit_stats":null,"previous_names":[],"tags_count":5,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/int02h%2Fprimaree","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/int02h%2Fprimaree/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/int02h%2Fprimaree/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/int02h%2Fprimaree/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/int02h","download_url":"https://codeload.github.com/int02h/primaree/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":253857186,"owners_count":21974694,"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":[],"created_at":"2024-08-01T19:01:41.334Z","updated_at":"2025-05-13T02:21:41.848Z","avatar_url":"https://github.com/int02h.png","language":"Kotlin","funding_links":[],"categories":["Kotlin"],"sub_categories":[],"readme":"# Primaree\n[![Build Status](https://travis-ci.com/int02h/primaree.svg?branch=master)](https://travis-ci.com/github/int02h/primaree)\n[![Latest release](https://img.shields.io/github/release/int02h/primaree.svg)](https://github.com/int02h/primaree/releases/latest)\n\nPrimaree - a simple library for safe initialization of multi-process\nAndroid applications.\n\n### But I have only one process\n\nYou think so. But if you take a look at your merged\n`AndroidManifest.xml` you may notice that there are some services,\ncontent providers or other Android components that specify\n`android:process` - so they work in different processes.\n\n### What's the problem?\n\nThe problem is that your `Application.onCreate()` method is being called\nas many times as many processes your application has. It means that you\ncan accidentally initialize your code twice, thrice or even more times.\nThis may lead to deadlocks or concurrent access to entities that are not\nsupposed to have concurrent access. For example, SQLite.\n\n### What Primaree actually does?\n\nJust look at the following code:\n\n```kotlin\nclass App : PrimareeApplication() {\n\n    override fun onPrimaryCreate() {\n        // ...\n    }\n\n    override fun onSecondaryCreate(name: String) {\n        // ...\n    }\n\n    override fun onPrimaryConfigurationChanged() {\n        // ...\n    }\n\n    override fun onSecondaryConfigurationChanged(name: String) {\n        // ...\n    }\n}\n```\n\nPrimaree provides abstract class `PrimareeApplication` you can inherit\nfrom. Its main purpose is to separate every considerable call in\nApplication (such as `onCreate` or `onConfigurationChanged`) into two\ncalls like `onPrimaryCreate` and `onSecondaryCreate`. These methods are\ncalled in the primary process of your application and every secondary\nprocess respectively. All secondary calls also receive the name of the\nsecondary process as their argument in the same format it appears in\n`AndroidManifest.xml`.\n\nIt worth to be mentioned that `onCreate` and other considerable calls\nare marked `final` so you forced to split your app initialization for\nprimary and secondary processes. It makes you never forget that\nthe application is multi-process.\n\n### What if my application class inherits another base class?\n\nIn this situation, Primaree is still able to help. It has few handy\nextensions for the Application class. You may use them as the following:\n\n```kotlin\nclass App : Application() {\n    \n    override fun onCreate() {\n        super.onCreate()\n\n        runIfPrimaryProcess {\n            // do something in primary process\n        }\n\n        if (isPrimaryProcess) {\n            // do something in primary process\n        } else {\n            // do something in secondary process\n        }\n    }\n    \n}\n```\n\n## Download\n\nAdd the following dependency to your `build.gradle` script:\n\n```groovy\ndependencies {\n    implementation 'com.dpforge:primaree:1.2.2'\n}\n```\n\n## License\n\nCopyright (c) 2023 Daniil Popov\n\nLicensed under the [MIT](LICENSE) License.","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fint02h%2Fprimaree","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fint02h%2Fprimaree","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fint02h%2Fprimaree/lists"}