I've tried various approaches and never succeeded, even tried spring (not sure if it's good for FE), I simply want to send a string form an android client (from a textfield by send would be even better) to an api (local in the network) so that I can start specifying the api etc... I started a Springboot tomcat Server with intellij an ran this or more or less similar code on android studio and nothing ever arrived on my localhost: '''
package com.example.test
import android.content.Intent
import androidx.appcompat.app.AppCompatActivity
import android.os.Bundle
import android.view.View
import android.widget.EditText
import android.widget.TextView
import android.widget.Toast
import com.android.volley.Request
import com.android.volley.Response
import com.android.volley.toolbox.StringRequest
import com.android.volley.toolbox.Volley
import org.w3c.dom.Text
const val EXTRA_MESSAGE = "com.example.tbv.MESSAGE"
var text: String = ""
class MainActivity : AppCompatActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_main)
}
fun sendApi() {
val queue = Volley.newRequestQueue(this)
val url = "http://192.168.178.70:8080/testApi" //also tested 10.0.2.2
val stringRequest = StringRequest(
Request.Method.GET, url,
{ response ->
text = "Response is: ${response.substring(0, 500)}"
},
{ text = "That didn't work!" })
queue.add(stringRequest)
Toast.makeText(this, "respooooonse", Toast.LENGTH_LONG).show()
startActivity(intent)
}
}
'''
as said, I've tried a variety of approaches, so I'm looking more for a general error in my approach. Screenshot
so the api should be sent as the response toast is showing. the request should show in the localhost 8080? im sending it from androidstudio to my local ip (in this case 192.168.178.70) Also tried sending to 10.0.2.2:8080, changing settings in the emulator and adding server.address=127.0.0.1 to application.properties in intellij