Skip to content

LinkSheet/interconnect

Repository files navigation

LinkSheetInterConnect

A way to communicate with LinkSheet, allowing your app to see which domains LinkSheet will send to it and to request domains be selected.

Installation

Add JitPack to your Maven repos:

maven(url="https://jitpack.io")

Add the dependency:

implementation("com.github.1fexd:LinkSheetInterConnect:<VERSION>")

Usage

The LinkSheet object has most of the needed utilities for connecting to LinkSheet.

Installation Status

To check if LinkSheet is installed, use isLinkSheetInstalled():

val linkSheetInstalled = with (LinkSheet) {
    context.isLinkSheetInstalled()
}

Interconnect Support

To check if the installed LinkSheet supports the interconnect service, use supportsInterconnect():

val supportsInterconnect = with (LinkSheet) {
    context.supportsInterconnect()
}

This function will also return false if LinkSheet isn't installed.

Bind to LinkSheet

To bind to the LinkSheet service, use bindService().

In Kotlin, you can use the suspend version of the function in a Coroutine scope to avoid using callbacks:

val connection = with (LinkSheet) {
    context.bindService()
}

In Java, or if you don't have a suspend context available, you can use the callback version:

with (LinkSheet) {
    context.bindService { connection ->
        // Use the connection here.
    }
}

Using the Connection

When you bind to LinkSheet with the bindService() function, a LinkSheetServiceConnection is provided to you.

This implements all functions LinkSheet supports and adds a disconnect() function that should be called when you're done communicating with LinkSheet.

LinkSheetServiceConnection also implements ServiceConnection. The disconnect() function is just a convenient way to unbind LinkSheet.