update docs to show how to check if amber is installed

This commit is contained in:
greenart7c3
2024-01-22 11:20:36 -03:00
parent 982c1acb77
commit b4ad213d48
+20 -2
View File
@@ -16,14 +16,32 @@ Amber is a nostr event signer for Android. It allows users to keep their nsec se
Amber uses Intents and Content Resolvers to communicate between applications.
To be able to use Amber in your application you should add the following package visibility needs:
To be able to use Amber in your application you should add the following in your AndroidManifest.xml:
```xml
<queries>
<package android:name="com.greenart7c3.nostrsigner"/>
<intent>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.BROWSABLE" />
<data android:scheme="nostrsigner" />
</intent>
</queries>
```
Then you can use this function to check if there's an external signer installed:
```kotlin
fun isExternalSignerInstalled(context: Context): Boolean {
val intent =
Intent().apply {
action = Intent.ACTION_VIEW
data = Uri.parse("nostrsigner:")
}
val infos = context.packageManager.queryIntentActivities(intent, 0)
return infos.size > 0
}
```
## Using Intents
To get the result back from Amber 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.