Android:Method getText().tostring()出了问题!请问要怎么修改?

public void connect() {
AsyncTask read = new AsyncTask() {
private String[] values;

        @Override
        protected Void doInBackground(Void... arg0) {
            try {
                socket = new Socket(**ip.getText().toString(),** 12345); //这里出了问题
                writer = new BufferedWriter(new OutputStreamWriter(socket.getOutputStream()));
                reader = new BufferedReader(new InputStreamReader(socket.getInputStream()));
                publishProgress("@success");
            } catch (IOException e) {
                Toast.makeText(MainActivity.this, "Build fail!", Toast.LENGTH_SHORT).show();
                e.printStackTrace();
            }

            try {
                String line = null;
                while ((line = reader.readLine()) != null) {
                    publishProgress(line);
                }
            } catch (IOException e) {
                e.printStackTrace();
            }
            return null;
        }

什么问题,是不是ip是null,访问出错

前面已经写了 ip = findViewById(。。。。。)
问题是那个getText要在UI线程才可以
可是网上的视频里别人也是这么写的呀
下载了原代码也是这里出错
真不知道视频里是怎么运行的