Add android example

This commit is contained in:
Ademar Alves de Oliveira
2023-07-26 10:02:04 -03:00
parent a819f995e6
commit 97d0d491a0
12 changed files with 407 additions and 24 deletions

View File

@@ -89,6 +89,41 @@ do {
</section>
<div slot="title">Android</div>
<section>
## Connecting
```kotlin
// SDK events listener
class SDKListener : EventListener {
override fun onEvent(e: BreezEvent) {
Log.v("SDKListener", "Received event $e")
}
}
// Select your seed, invite code and eviroment
val seed = mnemonicToSeed("<mnemonics words>")
val inviteCode = "your invite code"
val environmentType = EnvironmentType.PRODUCTION
// Create the default config
val greenlightNodeConfig = GreenlightNodeConfig(null, inviteCode)
val nodeConfig = NodeConfig.Greenlight(greenlightNodeConfig)
val config = defaultConfig(environmentType, inviteCode, nodeConfig)
// Customize the config object according to your needs
config.workingDir = "path to an existing directory"
try {
// Connect to the Breez SDK make it ready for use
val sdk = connect(config, seed, SDKListener())
} catch (e: Exception) {
// handle error
}
```
</section>
<div slot="title">React Native</div>
<section>
@@ -294,6 +329,20 @@ do {
```
</section>
<div slot="title">Android</div>
<section>
```kotlin
try {
val nodeInfo = sdk.nodeInfo()
val lnBalance = nodeInfo?.channelsBalanceMsat
val onchainBalance = nodeInfo?.onchainBalanceMsat
} catch (e: Exception) {
// handle error
}
```
</section>
<div slot="title">React Native</div>
<section>