Android
Android software development is the process by which applications are created for devices running the Android operating system.

Let's Get your Android App running with SAWO
πŸ™Œ
​

Requirements

​​
​
​

Steps

1. Add the following line to the root of setting.gradle repositories block.
1
maven { url 'https://jitpack.io' }
Copied!
2. Add this to your app level build.gradle android block.
1
compileOptions {
2
sourceCompatibility JavaVersion.VERSION_1_8
3
targetCompatibility JavaVersion.VERSION_1_8
4
}
5
​
6
kotlinOptions {
7
jvmTarget = '1.8'
8
}
Copied!
3. Add this to your app level build.gradle dependencies block
1
implementation 'com.github.sawolabs:Android-SDK:0.1.8'
Copied!
4. Sync your project.
5. To use SAWO Login you would need an API key which can be obtained by creating a project in the sawo dashboard.
6. Copy the API key from the project and keep it safe and secure.
The best practice to store your API key is to store values in .env so that they are not exposed.
7. Create an Activity in Android Studio to get login success response for this example lets assume it is CallbackActivity.
8. In your MainActivity add a button to login and add following code to its onclick handle.
Java
1
import com.sawolabs.androidsdk.Sawo;
2
​
3
public void onClickLogin(View view) {
4
new Sawo(
5
this,
6
"", // your api key
7
"" // your api key secret
8
).login(
9
"email", // can be one of 'email' or 'phone_number_sms'
10
CallbackActivity.class.getName() // Callback class name
11
);
12
}
Copied!
Kotlin
1
import com.sawolabs.androidsdk.Sawo
2
​
3
fun onClickLogin(view: View) {
4
Sawo(
5
this,
6
"", // your api key
7
"" // your api key secret
8
).login(
9
"email", // can be one of 'email' or 'phone_number_sms'
10
CallbackActivity::class.java.name // Callback class name
11
)
12
}
Copied!
10. Get the response payload in the CallbackActivity
Java
1
import com.sawolabs.androidsdk.ConstantsKt;
2
​
3
Intent intent = getIntent();
4
String message = intent.getStringExtra(ConstantsKt.LOGIN_SUCCESS_MESSAGE);
5
​
6
// continue with your implementation
Copied!
Kotlin
1
import com.sawolabs.androidsdk.LOGIN_SUCCESS_MESSAGE
2
​
3
val message = intent.getStringExtra(LOGIN_SUCCESS_MESSAGE)
4
// continue with your implementation
Copied!
Once the SAWO SDK is successfully set up, a login form will be rendered in the provided container as displayed in the picture below:
Final Render of SAWO Login
Congratulations !! The SAWO API is now ready to be used in your Andriod application 🀘.

You can also check out SAWO's Andriod Sample Code(Kotlin).

It's okay, we get it! You got Stuck!
😞
Feel free to contact us on #ask-for-help on our Discord​

Last modified 1mo ago