# Licence activation

The license can be set by sending extras on an Intent delivered to the application's **Activity**.  
The purchase key (or UUID) and the license key can be provided for the activation.

The extra names are:

```kotlin
val EXTRA_PK = "purchaseKey"
val EXTRA_LK = "licenseKey" // Optional
```

- `purchaseKey` is mandatory.
- `licenseKey` is optional. If provided we'll use it for the activation, otherwise we'll retrieve any remaining license key available in the purchase.

If any of those key is provided but doesn't exist are is already used by another device it'll trigger an error displayed in the application with the reason and the keys used.

## Activation by code

```kotlin
val SEND_PACKAGE = "com.benomad.benav"
val SEND_CLASS   = "com.benomad.benav.MainActivity"
val EXTRA_PK     = "purchaseKey"
val EXTRA_LK     = "licenseKey"   // optional

val i = Intent()
i.component = ComponentName(SEND_PACKAGE, SEND_CLASS)
i.flags = Intent.FLAG_ACTIVITY_NEW_TASK
i.putExtra(EXTRA_PK, "<valid_purchase_key>")
i.putExtra(EXTRA_LK, "<valid_license_key>")
startActivity(i)          // NOT sendBroadcast - the keys are read by MainActivity
```

> **Warning:** These extras are read by `MainActivity`, so they must be sent with `startActivity`. A **broadcast** carrying them is ignored: the RNC broadcast receiver only reads `BND_MESSAGE`.

## Activation with deeplink

1. Embed a link in an HTML file: `<a href="benav://licensing/purchaseKey=<valid_purchase_key>/licenseKey=<valid_license_key>">Click here to activate BeNav</a>`.
2. Open HTML file on the device and click link.

## Activation with QR code

1. Generate QR code with deep link: `benav://licensing/purchaseKey=<valid_purchase_key>/licenseKey=<valid_license_key>`.
2. Open the BeNav5.
3. Scan QR code with device camera.
