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);
| Parameter | Type | Required | Default | Description |
|---|---|---|---|---|
context | Context | Yes | — | Android application context |
appId | String | Yes | — | Your app ID from the OpenLynk dashboard |
apiKey | String | Yes | — | Your API key (format: ol_...) |
baseURL | String | No | "https://openlynk.io" | API base URL |
config | OpenlynkSDKConfig | No | Default config | SDK configuration options |
Methods
All methods are callback-based.
| Method | Callback | Description |
|---|---|---|
init() | — | Initialize the SDK (fire-and-forget) |
init(InitCallback) | InitCallback | Initialize the SDK with completion callback |
handleIncomingUri(Uri, HandleUriCallback) | HandleUriCallback | Parse an incoming App Link URI |
parseDeepLink(Uri, ParseDeepLinkCallback) | ParseDeepLinkCallback | Parse a deep link URI manually |
createLink(String, JSONObject, CreateLinkCallback) | CreateLinkCallback | Create a deep link with metadata |
createLink(String, CreateLinkCallback) | CreateLinkCallback | Create a deep link without metadata |
restorePendingLinks(String, RestoreCallback) | RestoreCallback | Restore deferred links by user email |
restorePendingLinksForAnonymous(RestoreCallback) | RestoreCallback | Restore deferred links using device fingerprint |
getLinkBySlug(String, String, GetLinkCallback) | GetLinkCallback | Fetch 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() { ... };
| Field | Type | Default | Description |
|---|---|---|---|
autoRestoreOnInit | boolean | true | Automatically restore pending links when init() is called |
userEmailProvider | UserEmailProvider | null | Interface that provides the current user's email |
onRestoredLinks | OnRestoredLinksListener | null | Listener invoked when deferred links are restored |
onDeepLink | OnDeepLinkListener | null | Listener 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);
}
Related Pages
- Data Types Reference — full field-level documentation for
CreatedLink,ParsedDeepLink,RestoredLink, andLinkDetails - Android App Links Guide — configure App Links for your app
What's Next?
- Configure App Links so deep links open your app
- Learn how to handle deep links in your Android app
- Implement deferred deep linking for users who install after clicking a link