diff options
| author | Xavier Del Campo Romero <xavi.dcr@tutanota.com> | 2023-04-13 00:54:02 +0200 |
|---|---|---|
| committer | Xavier Del Campo Romero <xavi.dcr@tutanota.com> | 2023-10-02 23:30:38 +0200 |
| commit | c64a043a8e28675e5349223e35fc5245deae6dfd (patch) | |
| tree | a2def07614806e8837c5c380f16545937bee294f | |
| parent | 162f0d4f619f76b7fafc28f683ca8ddfa9d44a46 (diff) | |
HelloWorld.java: Use HTTPSURLConnection
| -rw-r--r-- | HelloWorld.java | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/HelloWorld.java b/HelloWorld.java index 45d4eb8..d118cee 100644 --- a/HelloWorld.java +++ b/HelloWorld.java @@ -2,8 +2,9 @@ import helloworld.R; import android.app.Activity; import android.os.Bundle; import android.widget.TextView; -import java.net.HttpURLConnection; +import java.io.OutputStream; import java.net.URL; +import javax.net.ssl.HttpsURLConnection; public class HelloWorld extends Activity { @Override @@ -11,10 +12,14 @@ public class HelloWorld extends Activity { try { URL url = new URL("https://slcl.privatedns.org"); + HttpsURLConnection c = (HttpsURLConnection) url.openConnection(); - HttpURLConnection urlConnection = (HttpURLConnection) url.openConnection(); + c.setFollowRedirects(true); + + OutputStream os = c.getOutputStream(); + System.out.println("Response code:" + c.getResponseCode()); } catch (Exception e) { - //TODO: handle exception + System.out.println("Exception: " + e.getMessage()); } super.onCreate(savedInstanceState); |
