{"id":15458922,"url":"https://github.com/nisrulz/lantern","last_synced_at":"2026-03-01T08:34:46.485Z","repository":{"id":51609116,"uuid":"92693350","full_name":"nisrulz/lantern","owner":"nisrulz","description":"🏮[Android Library] Handling device flash as torch for Android.","archived":false,"fork":false,"pushed_at":"2023-12-07T10:31:45.000Z","size":1234,"stargazers_count":84,"open_issues_count":10,"forks_count":24,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-04-15T06:12:32.215Z","etag":null,"topics":["android","android-library","display","flashlight","screen","torch"],"latest_commit_sha":null,"homepage":"https://nisrulz.com/lantern/","language":"Java","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/nisrulz.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.txt","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},"funding":{"github":"nisrulz","ko_fi":"nisrulz","buy_me_a_coffee":"nisrulz","custom":["https://revolut.me/nisrulz","https://www.paypal.me/nisrulz/5eur"]}},"created_at":"2017-05-28T23:35:46.000Z","updated_at":"2024-12-08T09:33:00.000Z","dependencies_parsed_at":"2023-12-07T11:30:48.609Z","dependency_job_id":"9d87f537-797e-4d6c-8ddd-2e29527c9431","html_url":"https://github.com/nisrulz/lantern","commit_stats":{"total_commits":63,"total_committers":1,"mean_commits":63.0,"dds":0.0,"last_synced_commit":"4c74c702c313fcdd197069e7d0a0b3dec3c41de4"},"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"purl":"pkg:github/nisrulz/lantern","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nisrulz%2Flantern","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nisrulz%2Flantern/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nisrulz%2Flantern/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nisrulz%2Flantern/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/nisrulz","download_url":"https://codeload.github.com/nisrulz/lantern/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nisrulz%2Flantern/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29965406,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-03-01T06:55:38.174Z","status":"ssl_error","status_checked_at":"2026-03-01T06:53:04.810Z","response_time":124,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"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","display","flashlight","screen","torch"],"created_at":"2024-10-01T23:03:26.934Z","updated_at":"2026-03-01T08:34:46.462Z","avatar_url":"https://github.com/nisrulz.png","language":"Java","funding_links":["https://github.com/sponsors/nisrulz","https://ko-fi.com/nisrulz","https://buymeacoffee.com/nisrulz","https://revolut.me/nisrulz","https://www.paypal.me/nisrulz/5eur","https://www.paypal.me/nisrulz/5usd"],"categories":[],"sub_categories":[],"readme":"\u003cdiv align=\"center\"\u003e\n  \u003cimg src=\"img/logo_color.png\" height=\"128\" /\u003e\n\u003c/div\u003e\n\n\u003ch1 align=\"center\"\u003eLantern\u0026nbsp;\u003ca href=\"https://twitter.com/intent/tweet?text=Checkout%20Lantern%3A%20Android%20library%20handling%20flashlight%20for%20camera%20and%20camera2%20api%20%F0%9F%98%8E\u0026via=nisrulz\u0026hashtags=AndroidDev,android,library,OpenSource\"\u003e\n        \u003cimg src=\"https://img.shields.io/twitter/url/http/shields.io.svg?style=social\"/\u003e\n    \u003c/a\u003e\u003c/h1\u003e\n\n\u003cdiv align=\"center\"\u003e\n  \u003cstrong\u003eAndroid library handling flashlight for camera and camera2 api. Added support for handling display/screen light.\u003c/strong\u003e\n\u003c/div\u003e\n\u003cbr/\u003e\n\u003cdiv align=\"center\"\u003e\n    \u003c!-- Bintray --\u003e\n    \u003ca href=\"https://bintray.com/nisrulz/maven/com.github.nisrulz%3Alantern/_latestVersion\"\u003e\n        \u003cimg src=\"https://api.bintray.com/packages/nisrulz/maven/com.github.nisrulz%3Alantern/images/download.svg\"/\u003e\n    \u003c/a\u003e\n    \u003c!-- API --\u003e\n    \u003ca href=\"https://android-arsenal.com/api?level=14\"\u003e\n        \u003cimg src=\"https://img.shields.io/badge/API-14%2B-orange.svg?style=flat\"/\u003e\n    \u003c/a\u003e\n    \u003c!-- Android Arsenal --\u003e\n    \u003ca href=\"https://android-arsenal.com/details/1/5816\"\u003e\n        \u003cimg src=\"https://img.shields.io/badge/Android%20Arsenal-Lantern-brightgreen.svg?style=flat\"/\u003e\n    \u003c/a\u003e\n    \u003c!-- GitHub stars --\u003e\n    \u003ca href=\"https://github.com/nisrulz/lantern\"\u003e\n        \u003cimg src=\"https://img.shields.io/github/stars/nisrulz/lantern.svg?style=social\u0026label=Star\"/\u003e\n    \u003c/a\u003e\n    \u003c!-- GitHub forks --\u003e\n    \u003ca href=\"https://github.com/nisrulz/lantern/fork\"\u003e\n        \u003cimg src=\"hhttps://img.shields.io/github/forks/nisrulz/lantern.svg?style=social\u0026label=Fork\"/\u003e\n    \u003c/a\u003e\n    \u003c!-- GitHub watchers --\u003e\n    \u003ca href=\"https://github.com/nisrulz/lantern\"\u003e\n        \u003cimg src=\"https://img.shields.io/github/watchers/nisrulz/lantern.svg?style=social\u0026label=Watch\"/\u003e\n    \u003c/a\u003e\n    \u003c!-- Say Thanks! --\u003e\n    \u003ca href=\"https://saythanks.io/to/nisrulz\"\u003e\n        \u003cimg src=\"https://img.shields.io/badge/Say%20Thanks-!-1EAEDB.svg\"/\u003e\n    \u003c/a\u003e\n    \u003ca href=\"https://www.paypal.me/nisrulz/5usd\"\u003e\n        \u003cimg src=\"https://img.shields.io/badge/$-donate-ff69b4.svg?maxAge=2592000\u0026amp;style=flat\"\u003e\n    \u003c/a\u003e\n    \u003cbr/\u003e\n     \u003c!-- GitHub followers --\u003e\n    \u003ca href=\"https://github.com/nisrulz/lantern\"\u003e\n        \u003cimg src=\"https://img.shields.io/github/followers/nisrulz.svg?style=social\u0026label=Follow%20@nisrulz\"/\u003e\n    \u003c/a\u003e\n    \u003c!-- Twitter Follow --\u003e\n    \u003ca href=\"https://twitter.com/nisrulz\"\u003e\n        \u003cimg src=\"https://img.shields.io/twitter/follow/nisrulz.svg?style=social\"/\u003e\n    \u003c/a\u003e\n\u003c/div\u003e\n\n\u003cdiv align=\"center\"\u003e\n  \u003csub\u003eBuilt with ❤︎ by\n  \u003ca href=\"https://twitter.com/nisrulz\"\u003eNishant Srivastava\u003c/a\u003e and\n  \u003ca href=\"https://github.com/nisrulz/lantern/graphs/contributors\"\u003e\n    contributors\n  \u003c/a\u003e\n\u003c/div\u003e\n\u003cbr/\u003e\n\u003cbr/\u003e\n\n# Including in your project\nLantern is available in the Jcenter, so getting it as simple as adding it as a dependency\n```gradle\nimplementation \"com.github.nisrulz:lantern:{latest version}\"\n```\nwhere `{latest version}` corresponds to published version in [ ![Download](https://api.bintray.com/packages/nisrulz/maven/com.github.nisrulz%3Alantern/images/download.svg) ](https://bintray.com/nisrulz/maven/com.github.nisrulz%3Alantern/_latestVersion)\n\n# Usage\n\nLantern uses a fluent api. You can enable/disable feature by calling the right method on the Lantern object. Use what you need!\n\n1. Declare permissions in your app's `AndroidManifest.xml` file\n\n    ```xml\n    \u003c!-- Permissions : Allows access to flashlight --\u003e\n    \u003cuses-permission android:name=\"android.permission.CAMERA\"/\u003e\n    \u003cuses-permission android:name=\"android.permission.FLASHLIGHT\"/\u003e\n\n    \u003c!-- Permissions : Allows access to change system settings for handling screen states --\u003e\n    \u003cuses-permission android:name=\"android.permission.WRITE_SETTINGS\"/\u003e\n    ```\n\n1. Init code.\n\n    ```java\n    private Lantern lantern = new Lantern(this)\n                                // Check and request for system permission, used for handling screen states\n                                .checkAndRequestSystemPermission()\n                                // OPTIONAL: Setup Lantern to observe the lifecycle of the activity/fragment, handles auto-calling cleanup() method\n                                .observeLifecycle(this);\n\n    // Init Lantern's torch feature by calling `initTorch()`, which also check if camera permission is granted + camera feature exists\n    // In case permission is not granted, request for the permission and retry by calling `initTorch()` method\n    // NOTE: In case camera feature/hardware does not exist, `initTorch()` will return `false` and Lantern will not have\n    // torch functionality but only screen based features\n    if (!lantern.initTorch()) {\n        // Request camera permission if it is not granted\n        ActivityCompat.requestPermissions(this, new String[]{Manifest.permission.CAMERA}, REQUEST_CODE);\n    }\n\n\n    // Handle the runtime permission\n    @Override\n    public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions,\n            @NonNull int[] grantResults) {\n        super.onRequestPermissionsResult(requestCode, permissions, grantResults);\n\n        if (requestCode == REQUEST_CODE) {\n            // Retry initializing the Lantern's torch feature\n            if (!lantern.initTorch()) {\n                // Camera Permission Denied! Do something.\n            }\n        }\n    }\n    ```\n1. Cleanup\n    \u003e If you are not observing the lifecyle of the activity/fragment via `observeLifecycle(this)` method, then you\n    \u003e need to call `cleanup()` method in `onDestroy()` of the Activity.\n\n    ```java\n    @Override\n    protected void onDestroy() {\n        lantern.cleanup();\n        super.onDestroy();\n    }\n    ```\n1. Manage states via\n  \n    + Turn On\n\n        ```java\n        lantern\n            // Enable always on display\n            .alwaysOnDisplay(true)\n            // Set screen to full bright\n            .fullBrightDisplay(true)\n            // Or set screen to Auto Bright\n            .autoBright(true)\n            // Enable torch via flash\n            .enableTorchMode(true)\n            // Enable pulsating torch\n            .pulse(true)\n            // Set the delay for between each pulse\n            .withDelay(1, TimeUnit.SECONDS);\n        ```\n    + Turn Off\n\n        ```java\n        lantern\n            // Disable always on display\n            .alwaysOnDisplay(false)\n            // Unset full bright screen state\n            .fullBrightDisplay(false)\n            // Or unset screen from Auto Bright\n            .autoBright(false)\n            // Disable torch via flash\n            .enableTorchMode(false)\n            // Disable pulsating torch\n            .pulse(false);\n        ```\n\n# Pull Requests\nI welcome and encourage all pull requests. It usually will take me within 24-48 hours to respond to any issue or request. Here are some basic rules to follow to ensure timely addition of your request:\n  1. Match coding style (braces, spacing, etc.) This is best achieved using CMD+Option+L (Reformat code) on Mac (not sure for Windows) with Android Studio defaults. This project uses a [modified version of Grandcentrix's code style](https://github.com/nisrulz/AndroidCodeStyle/tree/nishant-config), so please use the same when editing this project.\n  2. If its a feature, bugfix, or anything please only change code to what you specify.\n  3. Please keep PR titles easy to read and descriptive of changes, this will make them easier to merge :)\n  4. Pull requests _must_ be made against `develop` branch. Any other branch (unless specified by the maintainers) will get rejected.\n  5. Check for existing [issues](https://github.com/nisrulz/lantern/issues) first, before filing an issue.\n  6. Have fun!\n\n\n## License\nLicensed under the Apache License, Version 2.0, [click here for the full license](/LICENSE.txt).\n\n## Author \u0026 support\nThis project was created by [Nishant Srivastava](https://github.com/nisrulz/nisrulz.github.io#nishant-srivastava) but hopefully developed and maintained by many others. See the [the list of contributors here](https://github.com/nisrulz/lantern/graphs/contributors).\n\n\u003e If you appreciate my work, consider buying me a cup of :coffee: to keep me recharged :metal:\n\u003e  + [PayPal](https://www.paypal.me/nisrulz/5usd)\n\u003e  + Bitcoin Address: 13PjuJcfVW2Ad81fawqwLtku4bZLv1AxCL\n\u003e\n\u003e Donation to the project is always welcome which helps to maintain and keep [my open source projects](https://github.com/nisrulz/) up to date!\n\n\u003cimg src=\"http://forthebadge.com/images/badges/built-for-android.svg\" /\u003e","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnisrulz%2Flantern","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnisrulz%2Flantern","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnisrulz%2Flantern/lists"}