# Deferred VPN Service Initialization

## Overview

See [Deferred VPN Service Initialization](/paas/sdk/unified-vpn-sdk/features/deferred-vpn-service-initialization.md)

## Implementation

1. Modify the `bools.xml` file:

   * Open your app's `res/values/bools.xml` file.
   * Add the following code snippet to define a boolean resource for controlling the VPN service:

   ```xml
   ...
   <resources>
       <bool name="vpn_process_enabled">false</bool>
   </resources>
   ```

   * Setting `vpn_process_enabled` to `false` initially disables the VPN service.
2. Enable the VPN service programmatically. Once the component is enabled, the SDK's standard VPN start flow can create the service on demand. In your app's code, add the following code snippet to enable the VPN service when desired:

   ```kotlin
   import unified.vpn.sdk.*

   val context = InstrumentationRegistry.getInstrumentation().targetContext
   val pm = context.packageManager
   pm.setComponentEnabledSetting(
       ComponentName(context, AFVpnService::class.java),
       PackageManager.COMPONENT_ENABLED_STATE_ENABLED,
       PackageManager.DONT_KILL_APP
   )

   // With the component enabled, initialize the SDK as usual.
   val clientInfo = ClientInfo.newBuilder()
       .addUrl("http://yourvpnbackend.com")
       .carrierId("YOUR_CARRIER_ID")
       .build()
   val sdk = UnifiedSdk.getInstance(clientInfo)
   ```
3. Rebuild and run your app.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://pango.gitbook.io/paas/sdk/vpn-sdk-for-android/features/deferred-vpn-service-initialization.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
