I'm trying to connect to a VPN, in order to have permissions to some web services that I request using HttpURLConnection. I need to enter the server and the credentials to the VPN, but I have no clue how to do that. I'm concerned that exists the vpnService but I didn't find how to use it and mainly how to pass credentials to it. Can you guys help me?
I want to establish the connection to a VPN from my university and, once did it, make the connections pass through it. I did it manually at the phone and It worked. Now I want to do it at the code so people that uses my app don't need to do that.
Edit: I just want to connect to a vpn programatically, instead of doing it through the vpn settings at android's settings menu.
Related
I'm developing android app. I need to connect my app to firebase real time db to get some information and authenticate my user. But, the problem is that I have to connect to firebase through proxy - our company proxy.
I checked some solutions to set proxy such as this. but this solutions will pass webView requests through proxy.
Is there any solution to pass firebase query requests through proxy?
Does anyone have any solution for that?
After many googling and testing different methods, I found that there is no way to use proxy for connecting my app to firebase real time db!
In order to round away this problem I find a solution: Using VPN tunneling connection in app (such as psiphon-tunnel-core) in order to tunnel all app traffic. But, the problem is that it required user approve to make VPN connection.
So, I think we should close this topic. But, if anyone anytime has any suggestion I will appreciate to add in comment.
I am developing an Android app that demands a signed-in VPN connection to access it. The problem I face is that, most of the end-users do not have any knowledge of creating a profile in some VPN, and then to connect to the app.
Is there a way to create a VPN Profile programmatically, and then Connect to it after the creation?
What I understand from your question is that, in order to access the app you are developing, it has to get signed-in to a VPN. If I am right, then you are typically in search of a Third-party API like facebook, twitter APIs, through which you should connect to your app. I suggest you to search if any VPN provide such kind of API service.
I have created a VPN Profile on my Android device. Now, I would like to create an Android application to manage (restrict and allow) which applications can access this VPN Profile.
So far, I've looked at Android's VPN Service which allows us to manage which applications can access the VPN Service but I am unable to correlate how this solution fits in with an already created VPN Profile.
There is no relation betweeen the VpnService API and VPN connections you create in Android's built-in VPN client. When using the VpnService API you'll have to implement a VPN protocol yourself and tunnel data read from the TUN device, which is created via the API, and back again (or use a library that implements a VPN protocol that does this for you), only then can you restrict apps from using the VPN using VpnService.Builder's addDisallowedApplication() method.
You can also look for VPN apps in the app store that already use this API and support excluding (or including) apps that may use the VPN.
you can find many free vpn or proxy servers. I use nord vpn and his efficiency I check on whats my ip service. You can also use it. Its free. VPN is important where you need to get access to blocked sites or social media like twitter or Facebook. During my trip to China I used vpn and whats my ip service.
I am developing the application in which I want to use VPN network. to create VPN network in device we need to configure it from (settings-wireless and network-VPN settings) menu of device.
I want to do this many settings via code with hard-coded information.
From API level 4.0 android provides API to handle the VPN services.
To know the implementation of this methods I used the Sample project of Android ToyVPN. But in this many methods I didn't find any method to pass username and password. information which I have to connect VPN network is.
VPN Server name
Username
Password
Using this three information I am successfully connecting to VPN network if I am configuring manually from device. But I want to do this programmatically. Here is the class file which is used to connect to VPN network. ToyVpnClient.java and ToyVpnService.java. in addition to this sample application is crashes in device.
Any help will be appreciated.
The VpnService you are talking about is not what you think. It's just a framework for you to create your own VPN solution. Once established, you'll get all communication on the network (IP) layer and you can do anything you want with it, e.g., encrypt it and send it to your server - the example for this is the ToyVpn project found in /samples/android-14/ directory. You also need a your own server side code to do the decryption and the necessary routing of the traffic.
Unfortunately you can't set the built-in android VPN programmatically. The best you can do is to show a dialog to the user explaining how to set it and then pop up the system settings with the correct screen showing.
It is possible using internal android.jar(com.android.internal) and hidden(#hide) API. Refer the below link:
How to programmatically create a new VPN interface with Android 4.0?
I'm trying to find a solution to listening for a request from a server.
The server would send a String to the phone, based on the ip address of the phone and the android app would take action when it happens.
Has anybody here faced a simular problem and can direct me to an example on the web or something?
Thanks
You can use sockets for it. See here and here.
You can't really be sure of a mobile device's IP address. It can change as you switch between WiFi hotspots, or as you move to a different 3G area. For this to work, the mobile has to register somehow with the server. The usual way to implement it is to keep an open connection, where the server responds with data only when it wants to notify the client. It is possible to create your own implementation, but not trivial. Android has a standard way to do this called Cloud to Device Messaging (C2DM). It is used by GMail and other Google apps, so it's fairly reliable. There are other services that provide something similar, you might want to look into those if C2DM doesn't fit your needs (it requires a Google account, etc.)