{"id":19726959,"url":"https://github.com/timtech4u/phonelock","last_synced_at":"2026-06-13T17:01:42.596Z","repository":{"id":91625868,"uuid":"141817963","full_name":"Timtech4u/phonelock","owner":"Timtech4u","description":null,"archived":false,"fork":false,"pushed_at":"2018-07-31T09:26:23.000Z","size":12876,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-02-28T02:03:38.647Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Java","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/Timtech4u.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","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}},"created_at":"2018-07-21T13:58:45.000Z","updated_at":"2018-09-05T14:03:25.000Z","dependencies_parsed_at":"2023-12-07T20:15:09.184Z","dependency_job_id":null,"html_url":"https://github.com/Timtech4u/phonelock","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/Timtech4u/phonelock","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Timtech4u%2Fphonelock","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Timtech4u%2Fphonelock/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Timtech4u%2Fphonelock/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Timtech4u%2Fphonelock/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Timtech4u","download_url":"https://codeload.github.com/Timtech4u/phonelock/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Timtech4u%2Fphonelock/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":34292326,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-06-13T02:00:06.617Z","response_time":62,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"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":[],"created_at":"2024-11-11T23:37:13.444Z","updated_at":"2026-06-13T17:01:42.578Z","avatar_url":"https://github.com/Timtech4u.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":"# FingerLock\nFingerLock is a library designed to make fingerprint authentication an easy task for Android developers.\n\n**Note**: this library is powered by [material-dialogs](https://github.com/afollestad/material-dialogs),\ndepending on this library will automatically depend on Material Dialogs.\n\nCheck the related post on [Medium.](https://medium.com/@aitorvs/android-fingerprint-authentication-44c047179d9a#.6kxauxim3)\n\n# Gradle Dependency\n\n[![](https://jitpack.io/v/com.github.aitorvs.fingerlock/core.svg)](https://jitpack.io/#com.github.aitorvs.fingerlock/core)\n[![](https://jitpack.io/v/com.github.aitorvs.fingerlock/dialog.svg)](https://jitpack.io/#com.github.aitorvs.fingerlock/dialog)\n[![Build Status](https://travis-ci.org/aitorvs/fingerlock.svg)](https://travis-ci.org/aitorvs/fingerlock)\n[![Android Arsenal](https://img.shields.io/badge/Android%20Arsenal-FingerLock-green.svg?style=true)](https://android-arsenal.com/details/1/4330)\n\n## Repository\n\n```gradle\nrepositories {\n    maven { url \"https://jitpack.io\" }\n}\n```\n\n## Dependencies\n\n### Core\n\nThe *core* module contains the core class `FingerLock` to perform full fingerprint authentication.\n\n```gradle\ndependencies {\n\n    // ... other dependencies here\n\n    compile 'com.github.aitorvs.fingerlock:core:1.0.0'\n}\n```\n\n### Fingerprint Dialog Extension\n\nThe *dialog* extension module is powered by [material-dialogs](https://github.com/afollestad/material-dialogs)\nlibrary and provides an out-of-the-box-ready material authentication dialog based on the design guidelines on fingerprint\nauthentication.\n\n```gradle\ndependencies {\n\n    // ... other dependencies here\n\n    compile 'com.github.aitorvs.fingerlock:dialog:1.0.0'\n}\n```\n### Manifest\n\nThe library requires the `USE_FINGERPRINT` permission. Just add the following to your `AndroidManifest.xml` file\n \n ```\n \u003cuses-permission android:name=\"android.permission.USE_FINGERPRINT\"/\u003e\n ```\n\n# Core\n\nThe core module requires Android M and above and also a device supporting fingerprint sensor. If you target\ndevices before M or not having fingerprint sensors, use the dialog extension.\n\n## (Core) FingerLock in 4 steps\n\n### 1. Implement the `FingerLockResultCallback` inside your Activity/Fragment\n\n```java\npublic class MainActivity extends AppCompatActivity\n        implements FingerLockResultCallback {\n        //...\n}\n```\n\n### 2. Initialize the library (e.g. inside `onCreate()` method)\n\n\n```java\n    @Override\n    protected void onCreate(Bundle savedInstanceState) {\n        private FingerLockManager mFingerLockManager;\n        \n        // ... Some code here\n\n        // returns a manager object to manage the fingerprint authentication\n        mFingerLockManager = FingerLock.initialize(this, KEY_NAME);\n    }\n```\n\n### 3. Start the fingerprint scanning\n\nIt is as simple as calling the `start()` method.\n\n```java\n    @Override\n    protected void onCreate(Bundle savedInstanceState) {\n        // ... Some code here\n\n\n        mButton = (Button) findViewById(R.id.button_authenticate);\n        mButton.setOnClickListener(new View.OnClickListener() {\n            @Override\n            public void onClick(View v) {\n                mFingerLockManager.start();\n            }\n        });\n\n        // ... Some more code here\n    }\n```\n\n### 4. Handle the callbacks\n\n#### Library is ready\n\n```java\n    @Override\n    public void onFingerLockReady() {\n        // Called right after registration if the device supports fingerprint authentication.\n        // This is normally a good place to call mFingerLockManager.start()\n    }\n```\n\nThis method is called when the library finishes the registration process successfully.\n\nThis is normally a good place to call `start()` so start the fingerprint(s) scanning process.\n\n\n#### Fingerprint(s) Scanning\n\n```java\n    @Override\n    public void onFingerLockScanning(boolean invalidKey) {\n        // Called to notify the fingerprint scanning is started successfully as a result of mFingerLockManager.start()\n        // The 'invalidKey' parameter will be true when the key is no longer valid. This happens when\n        // the user disables the lock screen, resets or adds a new fingerprint after the key was created (i.e. mFingerLockManager.register())\n    }\n```\n\nThe callback `onFingerLockScanning(boolean)` is called when the library has started\nscanning for fingerprint(s) to authenticate the user. The input parameter `invalidKey` flags when the key provided\nduring registration is no longer valid. Either because the user disabled the lock screen, device reset or\na new fingerprint was added.\nFor security purposes it is recommended to stop scanning fingerpring(s) calling `stop()` and\nfallback to any other type of authentication (i.e. password) that authenticates the user and let\nthem use fingerprint the next time.\n\n#### Authenticated\n\n```java\n    @Override\n    public void onFingerLockAuthenticationSucceeded() {\n        // Called when the user fingerprint has been correctly authenticated\n    }\n```\n\nThis method is called upon successful fingerprint authentication.\n\n#### Error\n\nThe callback provides error events that may happen throughout the fingerprint authentication process.\n\n```java\n    @Override\n    public void onFingerLockError(@FingerLock.FingerLockErrorState int errorType, Exception e) {\n        // Called every time there's an error at any stage during the authentication\n\n        switch (errorType) {\n            case FingerLock.FINGERPRINT_PERMISSION_DENIED:\n                // USE_PERMISSION is denied by the user, fallback to password authentication\n                break;\n            case FingerLock.FINGERPRINT_ERROR_HELP:\n                // there's some kind of recoverable error that can be solved. Call e.getMessage()\n                // to get help about the error\n                break;\n            case FingerLock.FINGERPRINT_NOT_RECOGNIZED:\n                // The fingerprint was not recognized, try another one\n                break;\n            case FingerLock.FINGERPRINT_NOT_SUPPORTED:\n                // Fingerprint authentication is not supported by the device. Fallback to password\n                // authentication\n                break;\n            case FingerLock.FINGERPRINT_REGISTRATION_NEEDED:\n                // There are no fingerprints registered in this device.\n                // Go to Settings -\u003e Security -\u003e Fingerprint and register at least one\n                break;\n            case FingerLock.FINGERPRINT_UNRECOVERABLE_ERROR:\n                // Unrecoverable internal error occurred. Unregister and register back\n                break;\n        }\n    }\n```\n\n# Dialog extension\n\nThe *dialog* extension module provides an out-of-the-box-ready material design dialog implementation\nthat follows the design rules for fingerprint authentication and handles the core library module for\nyou.\nThe dialog extension **automatically falls back to password authentication** when the device does not \nsupport fingerprint authentication.\n\n\n```java\npublic class MainActivity extends AppCompatActivity implements FingerprintDialog.Callback {\n\n    @Override\n    protected void onCreate(Bundle savedInstanceState) {\n        super.onCreate(savedInstanceState);\n\n        // show fingerprint dialog\n        FingerprintDialog.show(MainActivity.this, KEY_NAME, REQUEST_CODE);\n    }\n\n    @Override\n    public void onFingerprintDialogAuthenticated() {\n        // Authentication is successful\n    }\n\n    @Override\n    public void onFingerprintDialogVerifyPassword(final FingerprintDialog dialog, final String password) {\n        // Password verification has been requested. Use this method to verify the `password` passed\n        // as parameter against your backend\n\n        // Simulate exchange with backend\n        new Handler().postDelayed(new Runnable() {\n            @Override\n            public void run() {\n                dialog.notifyPasswordValidation(password.equals(\"aitorvs\"));\n            }\n        }, 1500);\n    }\n\n    @Override\n    public void onFingerprintDialogStageUpdated(FingerprintDialog dialog, FingerprintDialog.Stage stage) {\n        Log.d(TAG, \"Dialog stage: \" + stage.name());\n    }\n\n    public enum Stage {\n        FINGERPRINT,        // fingerprint authentication allowed\n        KEY_INVALIDATED,    // key invalidated, password to be required\n        PASSWORD            // password authentication selected by the user\n    }\n\n    @Override\n    public void onFingerprintDialogCancelled() {\n        Toast.makeText(this, R.string.dialog_cancelled, Toast.LENGTH_SHORT).show();\n    }\n}\n```\n\n## (Dialog) FingerLock in 3 steps\n\n### 1. Implement the dialog callbacks\n\n```java\npublic class MainActivity extends AppCompatActivity\n        implements FingerprintDialog.Callback {\n    //...Looooots of code here\n\n}\n```\n\n### 2. Create and show the dialog\n\n```java\n    @Override\n    protected void onCreate(Bundle savedInstanceState) {\n        super.onCreate(savedInstanceState);\n\n        // create and show the fingerprint dialog using the Builder\n        new FingerprintDialog.Builder()\n                .with(MainActivity.this)    // context, must call\n                .setKeyName(KEY_NAME)       // String key name, must call\n                .setRequestCode(69)         // request code identifier, must call\n                .show();                    // show the dialog\n    }\n```\n\nAdditionally, one could also call `setCancelable(Boolean)` in the builder\nto set the dialog as cancelable or not. This call is optional and default\nvalue is set to `true`.\n\n### 3. Handle callbacks\n\n#### Authenticated\n\n```java\n    @Override\n    public void onFingerprintDialogAuthenticated() {\n        // Authentication is successful\n    }\n```\n\n#### Verify password\n\n```java\n    @Override\n    public void onFingerprintDialogVerifyPassword(final FingerprintDialog dialog, final String password) {\n        // Password verification has been requested. Use this method to verify the `password` passed\n        // as parameter against your backend\n\n        // Simulate exchange with backend\n        new Handler().postDelayed(new Runnable() {\n            @Override\n            public void run() {\n                dialog.notifyPasswordValidation(password.equals(\"aitorvs\"));\n            }\n        }, 1500);\n    }\n```\n\nCalled when password verification is required. Either because triggered automatically when the provided\nkey is no longer valid or because the user required so.\n\nOnce the password is verified, notify the dialog calling `dialog.notifyPasswordValidation(boolean)`.\n\n#### State updated\n\n```java\n    @Override\n    public void onFingerprintDialogStageUpdated(FingerprintDialog dialog, FingerprintDialog.Stage stage) {\n        Log.d(TAG, \"Dialog stage: \" + stage.name());\n    }\n```\n\nMethod called at every internal stage change. Possible states are:\n\n```java\n    public enum Stage {\n        FINGERPRINT,        // fingerprint authentication allowed\n        KEY_INVALIDATED,    // key invalidated, password to be required\n        PASSWORD            // password authentication selected by the user\n    }\n```\n\nIt is normally not necessary to act on any of the stages.\n\n#### Authentication cancelled\n\nCalled when the user cancels the authentication dialog.\n\n```java\n    @Override\n    public void onFingerprintDialogCancelled() {\n        Toast.makeText(this, R.string.dialog_cancelled, Toast.LENGTH_SHORT).show();\n    }\n```\n\n# License\n```\nThe MIT License (MIT)\n\nCopyright (c) 2016 Aitor Viana Sanchez\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all\ncopies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\nSOFTWARE.\n```","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftimtech4u%2Fphonelock","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftimtech4u%2Fphonelock","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftimtech4u%2Fphonelock/lists"}