Skip to content
Anuj Middha edited this page Jun 29, 2017 · 2 revisions

Creating a simple login screen

Here is how you can quickly create a simple email-password based login screen with Argus. First step is to start configuring Argus. Best place to do it is in your Application class.

Configuration Code looks like this

loginProviders.add(new SimpleEmailLoginProvider());

// argus is customizable, supplying my custom logo to argus
ArgusTheme argusTheme = new ArgusTheme.Builder()

new Argus.Builder()
         // using default storage, don't want to do anything fancy here
         .argusStorage(new DefaultArgusStorage(getApplicationContext()))
         // this is the screen which should open after login is successfully completed
         .nextScreenProvider(new SimpleNextScreenProvider(HomeActivity.class))
         // we only want to implement login screen
         // set custom theme

Argus works with providers for features like Login/Signup/ForgotPassword. These Providers take care of all flow and functionality of the feature they are responsible for. Argus comes with builtin providers that are sufficient for most of the use cases, however, if those providers aren't enough for you, you can create your own custom provider. We will do a separate guide on how to create your own custom provider later.

For this example we will use EmailLoginProvider which comes by default with Argus. EmailLoginProvider is a abstract class which does all the work except final API call which is left for client code to handle. To do so you have to extend EmailLoginProvider. A simple implementation will look like this

public class SimpleEmailLoginProvider extends EmailLoginProvider {

     * this function is called after user input was validated
     * this is where actual API call to your server will go
    protected void doServerLogin(String username, String password) {
        // need to set state signed-in in Argus here
        if(username.equals("") && password.equals("password")) {
            // do a real API call here and in on success do following
            if (resultListener != null) {
        } else {
            if (context != null) {
                Toast.makeText(context, context.getString(R.string.invalid_email),

After that register ArgusActivity in your application's manifest file. Is it not mandatory to set ArgusActivity as launcher activity. You can also launch it via intent whenever your app requires login.

                <action android:name="android.intent.action.MAIN"/>
                <category android:name="android.intent.category.LAUNCHER"/>

Rest of the code is self explanatory. This will give you a login screen like this Simple Login with Argus

You can find above code in email-login-sample in Argus github repo.

Clone this wiki locally
You can’t perform that action at this time.