I have a problem to get a web page content in my Android App. I would like to read the contents from this address https://szr.szczecin.pl/utms/data/layers/VMSPublic .
At first I tried to do it in Java using this code:
public class Main {
public static void main(String[] args) {
String https_url = "https://szr.szczecin.pl/utms/data/layers/VMSPublic";
URL url;
try {
url = new URL(https_url);
HttpsURLConnection con = (HttpsURLConnection) url.openConnection();
print_content(con);
} catch (MalformedURLException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
}
private static void print_content(HttpsURLConnection con) {
if (con != null) {
try {
System.out.println("****** Content of the URL ********");
BufferedReader br = new BufferedReader(new InputStreamReader(con.getInputStream()));
String input;
while ((input = br.readLine()) != null) {
System.out.println(input);
}
br.close();
} catch (IOException e) {
e.printStackTrace();
}
}
}
}
It worked after I downloaded and installed the certificate from that webpage. How can I do the same in Android? I tried HTTPSURLConnection in Android but it returns me only the address of the web page. When I was trying HTTPURLConnection it gives me an information that document was moved (status 302).