SDKsAndroid
Deep Links
Handle App Links for Android deep linking with WarpLink.
When a user taps a WarpLink URL and your app is installed, Android opens your Activity via App Links. The SDK resolves the URI into a WarpLinkDeepLink with the destination, custom parameters, and attribution data.
Handle Incoming Links
Handle the intent in both onCreate() (cold start) and onNewIntent() (warm start).
import android.content.Intent
import android.os.Bundle
import androidx.appcompat.app.AppCompatActivity
import app.warplink.WarpLink
class MainActivity : AppCompatActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_main)
handleIntent(intent)
}
override fun onNewIntent(intent: Intent) {
super.onNewIntent(intent)
handleIntent(intent)
}
private fun handleIntent(intent: Intent?) {
intent?.data?.let { uri ->
WarpLink.handleDeepLink(uri) { result ->
result.onSuccess { deepLink ->
navigateTo(deepLink.destination)
}.onFailure { error ->
Log.e("MyApp", "Deep link error: ${error.message}")
}
}
}
}
}import android.content.Intent
import android.os.Bundle
import androidx.activity.ComponentActivity
import androidx.activity.compose.setContent
import app.warplink.WarpLink
class MainActivity : ComponentActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContent { MyApp() }
handleIntent(intent)
}
override fun onNewIntent(intent: Intent) {
super.onNewIntent(intent)
handleIntent(intent)
}
private fun handleIntent(intent: Intent?) {
intent?.data?.let { uri ->
WarpLink.handleDeepLink(uri) { result ->
result.onSuccess { deepLink ->
// Update navigation state or shared ViewModel
}.onFailure { error ->
Log.e("MyApp", "Deep link error: ${error.message}")
}
}
}
}
}The callback is always called on the main thread, so you can safely update UI from it.
Cold Start vs Warm Start
| Scenario | Entry Point | Behavior |
|---|---|---|
| Cold start | App not running — system launches Activity | onCreate() receives the intent with link URI |
| Warm start | App in background — brought to foreground | onNewIntent() receives the new intent |
Both cases use the same handleIntent helper.
Working with Deep Link Data
WarpLink.handleDeepLink(uri) { result ->
result.onSuccess { deepLink ->
Log.d("MyApp", "Link ID: ${deepLink.linkId}")
Log.d("MyApp", "Destination: ${deepLink.destination}")
// Android-specific deep link URL
deepLink.deepLinkUrl?.let { url ->
navigateToPath(url)
}
// Custom parameters
val productId = deepLink.customParams["product_id"] as? String
productId?.let { showProduct(it) }
}
}Error Handling
result.onFailure { error ->
when (error) {
is WarpLinkError.NotConfigured ->
Log.e("MyApp", "Call configure() first")
is WarpLinkError.InvalidUrl ->
Log.e("MyApp", "Not a WarpLink URL")
is WarpLinkError.LinkNotFound ->
showLinkExpired()
is WarpLinkError.NetworkError ->
showOfflineMessage()
is WarpLinkError.ServerError ->
Log.e("MyApp", "Server error ${error.statusCode}: ${error.message}")
else ->
Log.e("MyApp", "Error: ${error.message}")
}
}Verify assetlinks.json
WarpLink generates the Digital Asset Links file automatically. Verify it:
curl https://aplnk.to/.well-known/assetlinks.jsonCheck App Links verification status:
adb shell pm get-app-links com.yourcompany.yourappIf App Links aren't verified, try uninstalling and reinstalling the app. Android re-verifies assetlinks.json at install time.