Android Question How to access system settings

Tuxbox

Member
Licensed User
Hi,

I'm quite new to B4A. Installed the trial it 5 days ago, fell in love with it and bought it the next day.
I tried other tools before (even tried java/eclipse but it was too steep the learning curve) and was never fully satisfied. I love B4A and don't wish to move away from it.

I'm developing an App which constantly needs to update its info to and from a server. This must be done in the most transparent way for the end-user. I don't want him to worry about firewalls or proxies. If the android system knows how to reach the internet, the app needs to use these settings too.

I've read many threads talking about configuring the proxy of httputils manually but none of them relates to my specific issue. I need a way to read the proxy system settings (or any other system settings by the way: for future developments).

Help !
 

Tuxbox

Member
Licensed User
Thanks for your fast answer but here is my problem.
My app connects to my server through normal http on port 80 as any website.
I don't have any proxy on my home router and everything works fine.
At the office I have a firewall/proxy, and when testing the app there I get the following Error: java.net.ConnectException: - Connection refused
I've tested the default web browser and I can access my server address without any problem
If it's not proxy related, what else could it be??
 
Upvote 0

Tuxbox

Member
Licensed User
I configured it in the system settings.
But don't worry about my question, after some more test the website is not showing anymore in the default web browser, I think it could have been cached before. It looks like it is a wrong configuration on my proxy/firewall. I will dig some more. Sorry...
 
Upvote 0

Tuxbox

Member
Licensed User
After some tests, I found an internal issue:
- There was a defective wifi point in the office. Whenever the phone picked up the signal from this point there was no internet access. Which explained the incoherent behavior of some of my trials and error.

After disconnecting this faulty device I did some more tests and here are the results:
On a device using Android 5.1.1 everything works fine - no errors - proxy or not, the phone communicates with the server seamlessly.
On a device running Android 2.3.3 there is still an issue. Without the proxy, both the app and the internal browser work fine. With the proxy on, the app can't connect to the server anymore while the internal browser still can connect without any problem. I tried using both the httputils2 and okhttputils2 libraries and both fail to connect to the server giving the following error messages:
With HttpUtils2 - Error: org.apache.http.conn.HttpHostConnectException: Connection to http://???.??? refused
With oKhTTPuTILS2 - Error: java.net.ConnectException: ???.???/xxx.xxx.xxx.xxx:80 - Connection refused

Any clues ?
 
Upvote 0

Erel

B4X founder
Staff member
Licensed User
Longtime User
Upvote 0

Tuxbox

Member
Licensed User
1. I need to bother about Android 2.3 due to a specific target. The stats from developer.android.com is a worldwide statistic, my target is not. Following some research 50% of my target pool is still using Android 2.3.x
2. Setting up the proxy manually is not an option. But setting it up by reading system settings is. Which brings me back to my first inquiry: Is there a way to read/set Android system settings with B4A (maybe via reflector) ?
3. I didn't know we could get access to source code. Is there a specific repository where to download it?
4. Following my test result mentioned above, i'm not even sure it's a proxy problem anymore. I've checked my firewall and proxy logs, and there is no trace of the app connections but there is traces of the internet browser. I need to know how the default browser goes through. More digging ahead ...

--- update ---

After digging, I found out (i think!) that the Android 2.3 browser uses android.net.http.AndroidHttpClient which extends java.lang.Object and implements org.apache.http.client.HttpClient.
Is there an easy way to use this instead of okHttpClient or HttpClient ?
 
Last edited:
Upvote 0

Erel

B4X founder
Staff member
Licensed User
Longtime User
2. It is only possible to get the proxy settings in Android 4+.
3. HttpUtils2 is written in B4A. You can always make a search to find the source: https://www.b4x.com/android/forum/pages/results/?query=b4a+OkHttpUtils2&page=1&prefix=0

After digging, I found out (i think!) that the Android 2.3 browser uses android.net.http.AndroidHttpClient which extends java.lang.Object and implements org.apache.http.client.HttpClient.
Is there an easy way to use this instead of okHttpClient or HttpClient ?

It doesn't really matter how the browser is implemented. However HttpClient (HttpUtils2) is a wrapper above org.apache.http.client.HttpClient
 
Upvote 0
Top