Migration Guide From v1.1.0

Oneconnect Android SDK Migration Guide

From v1.1.0 🠒 v1.1.75

This section highlights updates to the OneConnect SDK, replacing deprecated patterns with modern implementations. It explains how to migrate from legacy server fetching and broadcast handling to the new, recommended APIs, ensuring compatibility with Android 13+ and providing cleaner, more reliable integration flows.


📋Changes to AndroidManifest.xml

Additional required permissions:

<uses-permission android:name="android.permission.FOREGROUND_SERVICE" />
<uses-permission android:name="android.permission.POST_NOTIFICATIONS"/>
<uses-permission android:name="android.permission.CHANGE_NETWORK_STATE" />
<uses-permission android:name="android.permission.FOREGROUND_SERVICE_SPECIAL_USE" />
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />

⚠️ Google Play Policy Note: If you publish your app, you must justify the use of FOREGROUND_SERVICE by submitting a video showing your app running in the background with notifications enabled.

Component Declarations Changes

Old declaration:

<activity
    android:name="top.oneconnectapi.app.DisconnectVPNActivity"
    android:excludeFromRecents="true"
    android:noHistory="true"
    android:taskAffinity=".DisconnectVPN"
    android:theme="@style/blinkt.dialog" />
<service
    android:name="top.oneconnectapi.app.core.OpenVPNService"
    android:permission="android.permission.BIND_VPN_SERVICE"
    android:exported="true">
    <intent-filter>
        <action android:name="android.net.VpnService" />
    </intent-filter>
</service>

New declaration:


🚀 Server Fetching Changes

Old Implementation:

New Implementation:

Instead of fetching raw JSON and parsing it manually, use the typed response listener. This returns lists of free and premium OneConnectServer objects directly. Here is a sample code.


🛑 Stopping VPN

Old implementation:

New implementation:

You no longer need to create an instance of OpenVPNThread. Instead, just launch the DisconnectVPN activity included in the SDK. By default, this will not open a new screen but instead display an alert dialog asking for confirmation. You can bypass the dialog and stop the connection immediately by passing the instantStop flag.


📡 Registering Receiver

Old implementation:

New implementation:

LocalBroadcastManager is deprecated. We now use registerReceiver with a namespaced action (top.oneconnectapi.app.VPN_STATS) to align with Android’s modern broadcast handling and ensure compatibility with Android 13+ requirements. Don't forget to unregister the receiver when you no longer need it.


Last updated