Skip to main content

Android SDK Reference (Java)

This page is a comprehensive API reference for the OpenLynk Android SDK (Java).

Installation

The SDK is distributed as a single file:

OpenlynkSDK.java

Add this file to your Android project. There are no external dependencies beyond the standard Android SDK.

Constructors

The SDK provides three constructor overloads:

// Minimal — uses default base URL and config
OpenlynkSDK sdk = new OpenlynkSDK(context, appId, apiKey);

// Custom base URL
OpenlynkSDK sdk = new OpenlynkSDK(context, appId, apiKey, baseURL);

// Full configuration
OpenlynkSDK sdk = new OpenlynkSDK(context, appId, apiKey, baseURL, config);
ParameterTypeRequiredDefaultDescription
contextContextYesAndroid application context
appIdStringYesYour app ID from the OpenLynk dashboard
apiKeyStringYesYour API key (format: ol_...)
baseURLStringNo"https://openlynk.io"API base URL
configOpenlynkSDKConfigNoDefault configSDK configuration options

Methods

All methods are callback-based.

MethodCallbackDescription
init()Initialize the SDK (fire-and-forget)
init(InitCallback)InitCallbackInitialize the SDK with completion callback
handleIncomingUri(Uri, HandleUriCallback)HandleUriCallbackParse an incoming App Link URI
parseDeepLink(Uri, ParseDeepLinkCallback)ParseDeepLinkCallbackParse a deep link URI manually
createLink(String, JSONObject, CreateLinkCallback)CreateLinkCallbackCreate a deep link with metadata
createLink(String, CreateLinkCallback)CreateLinkCallbackCreate a deep link without metadata
restorePendingLinks(String, RestoreCallback)RestoreCallbackRestore deferred links by user email
restorePendingLinksForAnonymous(RestoreCallback)RestoreCallbackRestore deferred links using device fingerprint
getLinkBySlug(String, String, GetLinkCallback)GetLinkCallbackFetch link details by slug and hostname

OpenlynkSDKConfig

OpenlynkSDKConfig config = new OpenlynkSDKConfig();
config.autoRestoreOnInit = true;
config.userEmailProvider = new UserEmailProvider() { ... };
config.onRestoredLinks = new OnRestoredLinksListener() { ... };
config.onDeepLink = new OnDeepLinkListener() { ... };
FieldTypeDefaultDescription
autoRestoreOnInitbooleantrueAutomatically restore pending links when init() is called
userEmailProviderUserEmailProvidernullInterface that provides the current user's email
onRestoredLinksOnRestoredLinksListenernullListener invoked when deferred links are restored
onDeepLinkOnDeepLinkListenernullListener invoked when a deep link is parsed

Callback Interfaces

CreateLinkCallback

public interface CreateLinkCallback {
void onSuccess(CreatedLink link);
void onError(Exception error);
}

RestoreCallback

public interface RestoreCallback {
void onSuccess(List<RestoredLink> links);
void onError(Exception error);
}

ParseDeepLinkCallback

public interface ParseDeepLinkCallback {
void onSuccess(ParsedDeepLink deepLink);
void onError(Exception error);
}

InitCallback

public interface InitCallback {
void onSuccess();
void onError(Exception error);
}

HandleUriCallback

public interface HandleUriCallback {
void onSuccess(ParsedDeepLink deepLink);
void onError(Exception error);
}

GetLinkCallback

public interface GetLinkCallback {
void onSuccess(LinkDetails details);
void onError(Exception error);
}

UserEmailProvider

public interface UserEmailProvider {
void getEmail(EmailCallback callback);
}

public interface EmailCallback {
void onEmail(String email); // pass null if no email available
}

OnRestoredLinksListener

public interface OnRestoredLinksListener {
void onRestoredLinks(List<RestoredLink> links);
}

OnDeepLinkListener

public interface OnDeepLinkListener {
void onDeepLink(ParsedDeepLink deepLink);
}

What's Next?