zkbnb Android SDK
Android SDK and demo for using zkbnb APIs in your Android app
Features
-
Fully open source
-
Written in Kotlin
-
Integration tests of SDK
-
Well tested
-
SDK Kotlin API reference HTML page
-
Comprehensive code documentation
-
Easier integration with Android studio plugin
-
All zkbnb HTTP APIs supported by the sdk
-
Full featured demo of SDK usage (Demo apk available to download from project Github)
-
UI tests of demo
-
Guide and demonstration video of SDK usage
Install
Using Android studio plugin
Go to Android Studio -> Settings -> Plugins
Search for zkbnb-android-sdk
and install it
SDK will now be ready to use. Proceed to usage section to get started with how to use the sdk.
Using Jitpack
Add Jitpack to your project level build.gradle
file
allprojects {
repositories {
...
maven { url 'https://jitpack.io' }
}
}
Add zkbnb sdk dependency in your app level build.gradle
file
implementation 'com.github.naman14:zkbnb-android-sdk:0.1'
API Reference
Full SDK API reference docs are available here
Usage
One time initialisation
We first need to initialise the SDK once at app launch. Your app’s Application class is the ideal location to do this one time initialisation.
// create a networkConfig to use in sdk
val networkConfig = NetworkConfig(
baseApiUrl = baseUrl, // base api url of the zkbnb api server
isDebug = true // if true, logs network requests to Android logcat
)
// initialise the sdk
ZkBNB.init(
applicationContext,
networkConfig
)
Attach a lifecycle to SDK (Optional)
ZkBNB.attach(lifecycle)
// lifecycle is directly available in activity or fragment
Attaching a lifecycle to sdk is recommended. It allows SDK to automatically cancel API calls if activity is destroyed.
Get data from SDK
Example - Get network status
ZkBNB.getNetworkStatus(object: TaskListener<NetworkStatus> {
override fun onError(e: Throwable) {
Log.d(TAG, e.message)
}
override fun onSuccess(data: NetworkStatus) {
Log.d(TAG, "Network status: ${data.status}, networkId: ${data.networkId}")
}
})
All supported APIs are listed here (All of the zkbnb HTTP APIs are currently supported by the Android SDK)-
Demo
A full featured demo is also included in the source code
Demo APK can also be directly downloaded from here
Plugin
For easier integration of SDK, we have also created an Android Studio plugin to quickly and easily get started with the sdk. Plugin can be installed by searching for ZkBNB Android
on Android Studio plugin marketplace or by downloading and importing plugin directly.
Download plugin