Idan
Idan

Reputation: 2879

Set android system wide proxy settings

I am looking into writing an Android tablet app as part of a wide parental control solution.

The app should set the tablet to work with a proxy server that will be used system wide (all apps on that device will be forced to go thought the proxy server).

The proxy server job will be to filter and monitor all outgoing connections from the tablet. As part of that, only specific sites will be available while most of the apps will be blocked (including the Google play store or any other communication app installed on the device).

As an extra, I want the user to not be able to change or remove the proxy settings if it's by monitoring and changing the settings back or by blocking the user with a password.

The actual proxy server is already running and functional. It is important the app will not require a custom ROM and/or root access

Can it be done?

Upvotes: 1

Views: 6073

Answers (2)

Kevin
Kevin

Reputation: 2730

I had the same problem for a while. I use a library that does http requests, but I can't acces the source. So I started digging and there were two things that I needed to do. One was to add this piece of code before my own http requests:

HttpClient httpClient = new DefaultHttpClient();
if (useProxy) {
  HttpHost proxy = new HttpHost("192.168.1.10", 8080, "http");
  httpClient.getParams().setParameter(ConnRoutePNames.DEFAULT_PROXY, proxy);
}
//use httpClient for a request here

But this did not solve my problem entirely. I couldn't access the source of the library that made it's own requests. I looked for more solutions and I found that you can use the following code to set a default proxy for all requests that your app makes.

System.setProperty("http.proxyHost", "192.168.1.10");
System.setProperty("http.proxyPort", "8080");

After adding this code, the requests from the library go through the proxy as well.

Upvotes: -1

RAJ
RAJ

Reputation: 44

By default the control app wont work without having access to the all system - means a root access- You can try to understand the principle used by Android Anti Virus software and that will help more.

By default as if now it is not possible to set Proxy for Apps ...

Upvotes: 2

Related Questions