add example of rememberLauncherForActivityResult

This commit is contained in:
greenart7c3 2024-03-18 15:10:25 -03:00 committed by GitHub
parent 6b26ebe6c5
commit a2aaa3c00b
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 24 additions and 0 deletions

24
100.md
View File

@ -40,6 +40,24 @@ fun isExternalSignerInstalled(context: Context): Boolean {
To get the result back from the Signer Application you should use `registerForActivityResult` or `rememberLauncherForActivityResult` in Kotlin. If you are using another framework check the documentation of your framework or a third party library to get the result.
```kotlin
val launcher = rememberLauncherForActivityResult(
contract = ActivityResultContracts.StartActivityForResult(),
onResult = { result ->
if (result.resultCode != Activity.RESULT_OK) {
Toast.makeText(
context,
"Sign request rejected",
Toast.LENGTH_SHORT
).show()
} else {
val signature = activityResult.data?.getStringExtra("signature")
// Do something with signature ...
}
}
)
```
Create the Intent using the **nostrsigner** scheme:
```kotlin
@ -52,6 +70,12 @@ Set the Signer package name:
intent.`package` = "com.example.signer"
```
Send the Intent:
```kotlin
launcher.launch(intent)
```
### Methods
- **get_public_key**