Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Set app level proxy

Tags:

I'm trying to create some sort of SDK that we intercept each request from my app regardless of which HTTP client it's using (be it native HttpURLConnection, OkHttp, Retrofit etc.). And including traffic from third-party libraries like Firebase Analytics etc.

I need to intercept and check few parameters then decide whether to allow or block current request.

I don't want to use any Custom VPN as it has some side effects like showing system level Notification and all traffic from the user device.

Is it possible to capture all requests by setting app level proxy? If possible, How to achieve it in code?

like image 431
VivekRajendran Avatar asked Jun 25 '18 06:06

VivekRajendran


People also ask

What is application level proxy?

An application proxy or application proxy server receives requests intended for another server and acts as the proxy of the client to obtain the requested service. You often use an application proxy server when the client and the server are incompatible for direct connection.

Do android proxy settings apply to all apps on the device?

No, they do not apply globally and without root there is no way to force a proxy to be used by all applications. The reason the message you found is worded that way is that it is up to the app creator to respect the proxy settings and use them or do the wrong thing and ignore them.


2 Answers

You can use Retrofit The retrofit will save your development time, And also you can keep your code in developer friendly. Retrofit has given almost all the API's to make a server call and to receive a response. internally they also use GSON to do the parsing. you can go through this link you will get more info Alos you can see the difference with other libs

like image 107
Milan Pansuriya Avatar answered Sep 28 '22 19:09

Milan Pansuriya


You could give a try to implement a custom VPN with https://developer.android.com/reference/android/net/VpnService. With this you should be able to control which traffic is allowed to access the internet and which not. As you wrote, that you'll create an SDK, the implementors should know the side effects of VPNs in apps (ongoing system notification, every traffic is routet through that VPN, etc.)

like image 31
Denis Loh Avatar answered Sep 28 '22 18:09

Denis Loh