January 2018
Intermediate to advanced
434 pages
14h 1m
English
Let's follow these steps to understand how to make a network request in Kotlin:
val response = URL("<api_request>").readText()
// 1. Declare a URL ConnectionURL url = new URL("http://www.google.com");HttpURLConnection conn = (HttpURLConnection) url.openConnection();// 2. Open InputStream to connectionconn.connect();InputStream in = conn.getInputStream();// 3. Download and decode the string response using builderStringBuilder stringBuilder = new StringBuilder();BufferedReader reader = new BufferedReader(new ...Read now
Unlock full access