Avatar ·

Wie erlaube ich alle Arten von Netzwerkverbindungen (HTTP und HTTPS) in Android 9 (Pie)?

Hallo zusammen! Ich bin neu in der Android-Entwicklung mit Kotlin und habe ein Problem mit Netzwerkanfragen unter Android 9 (Pie). In meiner App mache ich eine einfache GET-Anfrage an eine API, die über HTTP (nicht HTTPS) läuft. Hier ist der vereinfachte Code: ```kotlin class MainActivity : AppCompatActivity() { override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) setContentView(R.layout.activity_main) Thread { try { val url = URL("http://example.com/api/data") val connection = url.openConnection() as HttpURLConnection connection.requestMethod = "GET" val response = connection.inputStream.bufferedReader().readText() Log.d("Network", "Response: $response")