Avatar ·

How to allow all types of HTTP and HTTPS network connections in Android 9 (Pie)?

Hello everyone! I'm new to Android development in Kotlin, and I've encountered a problem with network requests on Android 9 (Pie). In my app, I'm making a simple GET request to an API that works over HTTP (not HTTPS). Here's the simplified 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") ```