# Android Deep Linking

LinkSense — a dynamic link management platform — supports Android App Links so a tap on a LinkSense URL opens directly in your Android app instead of Chrome. Android uses the Digital Asset Links file (`assetlinks.json`) to verify the link belongs to your app. LinkSense hosts this file automatically; you only need to register your app and add an intent filter.

## Prerequisites

- Your app's package name (e.g. `com.example.myapp`).
- Your app's SHA-256 signing certificate fingerprint.
- A Google Play Developer account (if publishing to the Play Store).
- A LinkSense project with a subdomain.

## Register your Android app

In the LinkSense dashboard, open your project's **Apps** tab and add an Android app. Provide:

- **App name** — friendly label.
- **Package name** — your app's package name.
- **SHA-256 fingerprint** — your signing certificate fingerprint (one or more entries).
- **Play Store link** — optional; used for fallback redirects when the app isn't installed.

### Finding your SHA-256 fingerprint

- **Production apps**: [Google Play Console](https://play.google.com/console) → Setup → App signing — copy both the upload and app signing key fingerprints.
- **Debug builds**: `keytool -list -v -keystore your-keystore.jks`

## Digital Asset Links

LinkSense generates and hosts the assetlinks.json file at:

```
https://<your-subdomain>.linksense.net/.well-known/assetlinks.json
```

Structure:

```json
[
  {
    "relation": ["delegate_permission/common.handle_all_urls"],
    "target": {
      "namespace": "android_app",
      "package_name": "com.example.myapp",
      "sha256_cert_fingerprints": [
        "AA:BB:CC:DD:EE:FF:00:11:22:33:44:55:66:77:88:99:..."
      ]
    }
  }
]
```

The file updates automatically when you add or remove Android apps from the project.

## Configure your Android app

Add an intent filter with `android:autoVerify="true"` to your `AndroidManifest.xml`:

```xml
<activity android:name=".MainActivity">
  <intent-filter android:autoVerify="true">
    <action android:name="android.intent.action.VIEW" />
    <category android:name="android.intent.category.DEFAULT" />
    <category android:name="android.intent.category.BROWSABLE" />
    <data
      android:scheme="https"
      android:host="your-subdomain.linksense.net" />
  </intent-filter>
</activity>
```

`autoVerify` tells Android to fetch your Digital Asset Links file at install time and verify it belongs to your app.

## Test App Links

1. Install your app on a physical device or emulator.
2. Verify the assetlinks.json with Google's Statement List Generator.
3. Open a messaging app and paste your dynamic link URL.
4. Tap the link — it should open directly in your app.

You can also force-test via ADB:

```bash
adb shell am start -a android.intent.action.VIEW \
  -d https://your-subdomain.linksense.net/your-path
```

If you change the Digital Asset Links configuration after install, users may need to reinstall the app or wait for the system to re-verify.

## See also

- [iOS Deep Linking](https://linksense.net/docs/ios-deep-linking.md)
- [Dynamic Links](https://linksense.net/docs/dynamic-links.md)
