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?
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.
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.
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
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.)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With