{"id":21977785,"url":"https://github.com/zapek/workerfragment","last_synced_at":"2026-05-07T07:34:52.385Z","repository":{"id":8989800,"uuid":"10738136","full_name":"zapek/WorkerFragment","owner":"zapek","description":null,"archived":false,"fork":false,"pushed_at":"2013-06-22T08:43:21.000Z","size":504,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-01-28T03:42:58.831Z","etag":null,"topics":["android","intentservice"],"latest_commit_sha":null,"homepage":"","language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/zapek.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2013-06-17T13:40:27.000Z","updated_at":"2021-01-25T10:36:31.000Z","dependencies_parsed_at":"2022-09-11T03:31:14.390Z","dependency_job_id":null,"html_url":"https://github.com/zapek/WorkerFragment","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zapek%2FWorkerFragment","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zapek%2FWorkerFragment/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zapek%2FWorkerFragment/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zapek%2FWorkerFragment/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/zapek","download_url":"https://codeload.github.com/zapek/WorkerFragment/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245040054,"owners_count":20551292,"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","intentservice"],"created_at":"2024-11-29T16:16:25.052Z","updated_at":"2026-05-07T07:34:47.357Z","avatar_url":"https://github.com/zapek.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":"WorkerFragment\n==============\n\nPurpose\n-------\nWorkerFragment is a mechanism that allows an Activity to start an IntentService and not lose its reply, even\nif the Activity is recreated (rotation, etc...).\n\nHow to use\n----------\nSimply copy WorkerFragment.java into your project, then on your Activity's onCreate() do this:\n\n    this.workerFragment = WorkerFragment.getWorkerFragment(this);\n\nIf savedInstanceState == null, you start your IntentService to do some background work:\n\n    Intent exampleIntent = new Intent(this, ExampleService.class);\n    exampleIntent.setAction(ExampleService.ACTION_GET_HELLO);\n    this.workerFragment.putReceiver(exampleIntent); /* this sets the WorkerFragment as receiver */\n    this.startService(exampleIntent);\n\nThen you implement the WorkerFragment.WorkerFragmentReceiver interface in your Activity to handle the result:\n\n    @Override\n    public void onReceiveResult(int resultCode, Bundle resultData) {\n    switch (resultCode)\n    {\n        case WorkerFragment.RESULTCODE_HELLOWORLD:\n        {\n            /* do your stuff here */\n        }\n        break;\n    }\n\nNow in your IntentService, sending your result is as simple as:\n\n    Bundle result = new Bundle();\n    result.putString(KEY_RESULT, \"hello world!\");\n    WorkerFragment.sendResult(intent, WorkerFragment.RESULTCODE_HELLOWORLD, result);\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzapek%2Fworkerfragment","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fzapek%2Fworkerfragment","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzapek%2Fworkerfragment/lists"}