android-simple/HelloWorld.java

35 lines
996 B
Java
Raw Normal View History

2023-04-13 00:00:19 +02:00
import helloworld.R;
2020-06-17 19:45:30 +02:00
import android.app.Activity;
import android.os.Bundle;
import android.widget.TextView;
import java.io.OutputStream;
2023-04-13 00:00:19 +02:00
import java.net.URL;
import javax.net.ssl.HttpsURLConnection;
2020-06-17 19:45:30 +02:00
public class HelloWorld extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
2023-04-13 00:00:19 +02:00
try {
2023-04-14 01:19:29 +02:00
Test t = new Test();
2023-04-13 00:00:19 +02:00
URL url = new URL("https://slcl.privatedns.org");
HttpsURLConnection c = (HttpsURLConnection) url.openConnection();
2023-04-13 00:00:19 +02:00
2023-04-14 01:19:29 +02:00
t.f();
c.setFollowRedirects(true);
OutputStream os = c.getOutputStream();
System.out.println("Response code:" + c.getResponseCode());
2023-04-13 00:00:19 +02:00
} catch (Exception e) {
System.out.println("Exception: " + e.getMessage());
2023-04-13 00:00:19 +02:00
}
2020-06-17 19:45:30 +02:00
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
TextView text = (TextView)findViewById(R.id.my_text);
text.setText("Hello, world!");
}
}