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_SERVICEby 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:
β Recommended Approach
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 theDisconnectVPNactivity 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 theinstantStopflag.
π‘ Registering Receiver
Old implementation:
New implementation:
LocalBroadcastManageris deprecated. We now useregisterReceiverwith 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