0

Hi I am trying to read from a simple database created in NetBeans into my app on android studio but I keep getting java.net.SocketTimeoutException: Read timed out error on execute. I have my XmlReaderTask class which uses AsyncTask and Retrofit as shown:

public class XmlReaderTask extends AsyncTask<Void, Void, String> {
    TableList tableList = new TableList();
    String responseText;
    Handler handler;
    TextView textView;
    protected String doInBackground(Void... voids) {
        Retrofit retrofit = new Retrofit.Builder()
            .baseUrl("https://10.0.2.2:8080/WebbTest2/webresources/")//http://10.0.2.2:8080/WebbTest2/webresources/se.miun.register?
            .addConverterFactory(SimpleXmlConverterFactory.create())
            .build();
        NameService service = retrofit.create(NameService.class);
        Call<TableList> listName = service.listNames();
        try {

            Response<TableList> result = listName.execute();
            TableList tableList = result.body();

            responseText = tableList.register.get(0).name;
        } catch (IOException e) {
            e.printStackTrace();
        }

        return responseText;

    }
    protected void onPostExecute(String result) {
        handler.post(new Runnable() {
            @Override
            public void run() {
                if(responseText!=null)
                    textView.setText(responseText);
            }
        });

    }

I am new to programming in android studio and I can't see what the mistake is, any ideas?

  • As I understand you are running a database from/in Netbeans and tries to connect from Android emulator to that database service. Probably you should explain what you have in Netbeans and check if you can connect from emulator to "localhost" https://stackoverflow.com/questions/5528850/how-do-you-connect-localhost-in-the-android-emulator . – PeterMmm Nov 28 '21 at 20:11

0 Answers0