敲代码的小哥 2016-01-15 09:35 采纳率: 50%
浏览 1658

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;
        }

  • 写回答

2条回答 默认 最新

  • bdmh 优质创作者: 移动开发技术领域 2016-01-15 09:44
    关注

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

    评论

报告相同问题?