每当我运行我的Android应用程序时,它就会停止,因为我点击了登录按钮

时间:2017-07-08 15:52:44

标签: android

第53行是这样的:

HttpsURLConnection httpsURLConnection=(HttpsURLConnection)url.openConnection();

第24行是这样的:

公共类BackGroundWork扩展了AsyncTask]

我附加的图像是错误列表中的错误。

1 个答案:

答案 0 :(得分:0)

  try this codes below: 

 URL url = new URL(Link);
  URLConnection connect = url.openConnection();





@Override
protected Object doInBackground(Object[] objects) {
    try {
        String data = URLEncoder.encode("tableName", "UTF8") + "=" + URLEncoder.encode(TableName, "UTF8") + "&" + "record" + "=" + RecordNo;
        //data
        URL url = new URL(Link);
        URLConnection connect = url.openConnection();
        connect.setDoOutput(true);
        OutputStreamWriter wr = new OutputStreamWriter(connect.getOutputStream());
        wr.write(data);
        wr.flush();
        String S = convetInputStreamToString(connect.getInputStream());

        assert S != null;
        if (!S.equals("no")) {
            GetUpdates.access = true;
            GetUpdates.res = S;
        } else {
            GetUpdates.access = false;
            GetUpdates.err = S;
        }
    } catch (IOException e) {
        e.printStackTrace();
    }
    return "";
}