KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
I am new to Android development. I am trying to join an existing VPN from my Android app. I want to integrate the VPN in my app; my app then is supposed to query a remote database. I got some code and tried to use it to create a VPN. It emulates the built-in VPN manager on the Android phone. The code compiles and the manager is launched but the connection to the VPN does not succeed when I try to connect after all configuration. The protocol is PPTP. A VPN exists and has been tested. I tried connecting from an android phone with the same settings and it was successful. I thought maybe I am passing the parameters in the wrong way. I have put the code for the vpn part below. The url is not the actual but in same format. Any help to identify what I am doing wrong would be appreciated. Also if there is a way I can directly call the VPN manager from my app. Thanks very much for any help, final Button button1 = (Button)findViewById(R.id.button1); final Button button2 = (Button)findViewById(R.id.button2); final Button button3 = (Button)findViewById(R.id.button3); button1.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { startActivity(new Intent("android.net.vpn.SETTINGS")); } }); button2.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { URL url = null; try { String registrationUrl = String.format("daffy.zune.org"); url = new URL(registrationUrl); URLConnection connection = url.openConnection(); HttpURLConnection httpConnection = (HttpURLConnection) connection; int responseCode = httpConnection.getResponseCode(); if (responseCode == HttpURLConnection.HTTP_OK) { Log.d("MyApp", "Registration success"); } else {
Tags (comma-separated)
Save Edits
Cancel