Search code examples
androidvpnandroid-vpn-service

VPN Connection for Android Studio Apps


I'm hoping to write an app in Android Studio which will require me to connect to a VPN.

I've read through the documentation on this, but I'm having trouble understanding some things about it, which the source code provided at the bottom of the article hasn't completely clarified to me.

  • Will this VpnService mean that I don't need to develop a separate VPN app for my main app to use for a VPN connection?

  • When the app opens for the very first time, I'll need to present a page for the user to enter the VPN details (IP address etc.) However, after these settings have been saved, how do I then open the VPN connection on app startup?


Solution

  • Answering your points.

    1. You don't need to develop a separate app for VPN. You can use the vpn service class for creating vpn connections.
    2. Just take the input from the user and pass them when configuring the vpn connection. Save the values in shared preferences and load from it for the next time use.