首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >(httplog)-static:启用-static的假android

(httplog)-static:启用-static的假android
EN

Stack Overflow用户
提问于 2016-02-23 06:05:30
回答 1查看 8.5K关注 0票数 5

我正在开发安卓应用程序,并在三星J7上运行。问题是,在运行该应用程序时,它会显示错误"( httplog )-static: it启用假“--是否有任何方法可以启用httplog或另一种解决此问题的方法。如果在程序上想要启用该功能,如何实现?

代码语言:javascript
复制
private void tryLogin(String log, String pass) {


            HttpURLConnection connection;
               OutputStreamWriter request = null;

                    URL url = null;   
                    String response = null;         
                    String parameters = "="+log+"&="+pass;   

                    try
                    {
                         url = new URL("http://209.68.26.95/anglertechnologieseit/lc_webservice/webservice.php?Case=loginCheck");
                        connection = (HttpURLConnection) url.openConnection();
                        connection.setDoOutput(true);
                        connection.setRequestProperty("Content-Type", "application/x-www-form-urlencoded");
                        connection.setRequestMethod("POST");    

                        request = new OutputStreamWriter(connection.getOutputStream());
                        request.write(parameters);
                        request.flush();
                        request.close();            
                        String line = "";               
                        InputStreamReader isr = new InputStreamReader(connection.getInputStream());
                        BufferedReader reader = new BufferedReader(isr);
                        StringBuilder sb = new StringBuilder();
                        while ((line = reader.readLine()) != null)
                        {
                            sb.append(line + "\n");
                        }
                       stored in response variable.                
                        response = sb.toString();

                    Toast.makeText(this,"Message from Server: \n"+ response, 0).show();             

                        System.out.println("Message from Serverrrrrrrrrrrr     :"+response);
                        isr.close();
                        reader.close();

                    }
                    catch(IOException e)
                    {
                        System.out.println("eeerrrrooorrr"+e);
                    }

        }

EN

回答 1

Stack Overflow用户

发布于 2020-02-22 10:49:00

我认为这与其说是错误,不如说是警告。如果您被这些消息垃圾邮件,您可以停用这种特定类型的错误(还有其他问题的堆栈溢出)。

我最初认为这是一个错误,因为我没有在我的服务器上接收任何数据。

我的错误是“守则”可能不起作用。(忘记请求响应代码)此代码可能会工作:

代码语言:javascript
复制
try { System.out.println("HTTP Upload");
        URL Singin_url = new URL("http://192.168.0.157:80");
        HttpURLConnection client = (HttpURLConnection)          
        Singin_url.openConnection();
        client.setRequestMethod("POST");
        client.setDoOutput(true);
        client.setDoInput(true);
        client.setConnectTimeout(10000); // 5 sec
        client.setReadTimeout(10000);

        OutputStream out = new BufferedOutputStream(client.getOutputStream());
        BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(out, "UTF-8"));
        String data = "POST_FROM_MOBILE";
        writer.write(data);
        writer.flush();
        writer.close();
        out.close();
        Log.e("E", String.valueOf(client.getResponseCode()));
    }catch(MalformedURLException error) {
        Log.e("Error","Wrong URL");
    }
    catch(SocketTimeoutException error) {
        Log.e("Error","Timeout");

    }
    catch (IOException error) {
        Log.e("Error","IOException Error");
    }

提示:使用调试器模式进行调试比较容易,因为您将看到更多的错误

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/35570059

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档