Integrate oneconnect SDK for Android
Current version:
OneConnect Android SDK Supported 16KB Page size
OneConnect.top SDK is an Android library that provides easy access to OneConnect API, allowing you to retrieve server information for VPN services. You can use this library to fetch both free and premium servers for your VPN application. persistent notifications, and real-time connection stats.
Migration Guide From v1.1.0
🛠 Installation
Add JitPack to your root
build.gradle:allprojects { repositories { ... maven { url "https://jitpack.io" } } }Add OneConnect SDK to your app-level
build.gradle:dependencies { implementation 'com.github.oneconnectapi:OneConnectLib:v1.1.75' //Change to latest version }
📋 Manifest Setup & Permissions
Add the following permissions to your AndroidManifest.xml:
⚠️ 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
Add these to your AndroidManifest.xml:
🔔 Request Notification Permission (Android 13+)
This permission is required for the SDK to display its persistent VPN notification correctly on Android 13 and above.
🚀 SDK Initialization & Server Fetching
Initialize the OneConnect SDK with your API key:
Fetch server lists asynchronously:
The
onSuccesscallback returns twoArrayList<OneConnectServer>objects:
freeServersList: list of free servers
premiumServersList: list of premium servers
Additonally:
You can fetch the raw JSON string instead:
Sample JSON response
🔐 VPN Connection Flow
Request VPN permission (Connection request):
Handle result:
Start VPN:
🛑 Stopping the VPN
With confirmation dialog:
Silent disconnect:
📡 VPN Status Monitoring
To receive real-time VPN connection stats from the OneConnect SDK, you must register a BroadcastReceiver for the top.oneconnectapi.app.VPN_STATS intent. These stats are emitted by the SDK during an active VPN session and can be used to update your VPN UI with live connection data.
Register receiver:
Handle stats:
These stats are ideal for updating your VPN UI with connection duration, traffic usage, and last packet timing. You can display them in your app’s status screen.
Unregister receiver:
Don't forget to unregister the receiver when it's no longer needed (e.g. in onDestroy()) to avoid memory leaks and unintended behavior.
In the code snippet above:
Ready demo project
Here we have ready demo project , you can frog from GitHub and use
Usage
This SDK Project is Created By OneConnect Team.
This Project Content OneConnect Library
For Use, the SDK Required OneConnect API Key,
Visit on this Website https://developer.oneconnect.top and Create Account and get the Key.
Once You have the OneConnect API Key, Then You have Put inside SplashScreen.java
You will Get the Key inside API Tab https://developer.oneconnect.top/dashboard/api/ After that, You need to Put Your App Package Name Inside OneConnect API Tab.

You have to Put inside SplashScreen.java Please See Screenshot

# This Project Content AdMob & Facebook Ads those developers want to Add Another Ads SDK they need to follow the Exiting Method of Ads SDK and Also Have IAP Subscription.
And Need to Put Your Google-Services.JSON file inside Project, You will get from Firebase.
Note :- Any Developer, those who want to Use or Sell for end Client
they need to make the sufficient Changes in the Original Demo Project.
Just Smile after get the Project..... (^_^)
Last updated
