I want to use 2 android devices, 1 as a server and 2 as a client. And this process should be through the local network, so the 1st device will have to open a hotspot and the 2nd device will have to connect to it. I did the same process but connect from 2 devices to the server It doesn't work. I don't understand what I should do in this case. I mean, which thread should I connect to?
Copy code
val client = HttpClient(Android) {
install(Logging)
}
object KtorClient {
var ipAddress: String = ""
var ipv4Address = ""
fun getData() {
GlobalScope.launch {
val data = client.request("http://$ipAddress:8080/api/data")
println("DATA:${data.call.body<String>()}")
}
}
fun otherGetData() {
GlobalScope.launch {
val data = client.request("https://$ipv4Address:8080/api/data")
println("DATA:${data.call.body<String>()}")
}
}
}
a
Aleksei Tirman [JB]
01/11/2024, 12:30 PM
How do you share the network between two Android devices?
b
Bekzod
01/11/2024, 1:14 PM
Hi @Aleksei Tirman [JB],
One device serves as server, and other (as client) sends request.