JAVA sketch not working in Android

I am working on an application which needs to get my router’s IP.
The following sketch works in JAVA.
Before running in Android, I checked the Internet option under Permissions.
With ANDROID, it compiles OK but does not work. I get a long error message, beginning with:
" (HTTPLog)-Static: isSBSettingEnabled false
java.io.IOException: Cleartext HTTP traffic to checkip.dyndns.com not permitted
………".

Thanks for any idea.

my sketch:

String ExtIP;
PFont font;
int Green=#4EFA2D;

void setup() {
size(400,200);

String[] lines = loadStrings(“http://checkip.dyndns.com”);
println(“there are " + lines.length + " lines”);
for (int i = 0 ; i < lines.length; i++) {
println(lines[i]);
}
ExtIP=lines[0];
ExtIP=ExtIP.substring(ExtIP.indexOf(“ss:”));
ExtIP=ExtIP.substring(4, ExtIP.indexOf("</"));
println(ExtIP);
font= createFont(“arial Bold”,32);
fill(Green);
textFont(font);
text(ExtIP,10,100);
}

void draw() {
}

1 Like

Hi @MPROCD give INTERNET permission to your app in Manifest and then try.

Hope this will resolve the issue.

thanks,
rana

Thank you Rana for this answer. I mentioned in my post that I enabled the Internet option under the sketch permissions. It did not solve the problem. I solved this issue the same way as I did in this post:

“Problem with processing.net.* library in Android](Problem with processing.net.* library in Android - #11 by MPROCD)”.

Thanks for trying to help.