mirror of
https://github.com/aljazceru/breez-sdk-docs.git
synced 2025-12-18 06:14:21 +01:00
Add android example
This commit is contained in:
@@ -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>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user