Docs

Lock for Android v1

Versionv1

This document covers an outdated version of Lock for Android. We recommend you to upgrade to v2.

Check out the Lock.Android repository on GitHub.

Requirements

Android API level 15+ is required in order to use Lock's UI. If you'll create your own API and just call Auth0 API via the com.auth0.android:core:1.+, the minimum required API level is 9.

Install

Lock is available both in Maven Central and JCenter. To start using Lock add these lines to your build.gradle dependencies file:

Once it's installed, you'll need to configure LockActivity in yourAndroidManifest.xml, inside the application tag:

The value @string/auth0_client_id is your application's clientID and @string/auth0_domain is your tenant's domain in Auth0, both values can be found in your app's settings.

The final value of android:scheme must be in lowercase.

Also, you'll need to add Internet permission to your application:

Finally, make your Application class (The one that extends from android.app.Application) implement the interface com.auth0.lock.LockProvider and add the following code:

You can check here for more configuration options

You should also add your Application class to the AndroidManifest.xml.

And include the following code in your build.gradle file.

Authentication with Lock

LockActivity will handle Email/Password, Enterprise & Social authentication based on your Application's connections enabled in your Auth0's Dashboard.

When a user authenticates successfully, LockActivity will send an Action using LocalBroadcastManager and then finish itself (by calling finish()). The activity that is interested in receiving this Action (In this case the one that will show Lock) needs to register a listener in the LocalBroadcastManager:

Then just start LockActivity

And you'll see our native login screen

Lock Screenshot

By default all social authentication will be done using an external browser, if you want native integration please check this wiki page.

Proguard

In the proguard directory you can find the Proguard configuration for Lock and its dependencies. By default you should at least use the following files:

  • proguard-square-okhttp.pro
  • proguard-jackson-2.pro
  • proguard-square-otto.pro
  • proguard-lock.pro

and if you use Facebook or Google+ native integration, you'll need proguard-facebook.pro and proguard-google-play-services.pro respectively.

You specify several files in you application's build.gradle like this: