android中HttpResponse中AndroidRuntime错误
阿神
阿神 2017-04-17 14:37:03
0
1
563

会报这个 错误

10-23 22:52:26.218: E/AndroidRuntime(7298):     at com.example.test_help.post.Cust_post.first(Cust_post.java:36)
10-23 22:52:26.218: E/AndroidRuntime(7298):     at com.example.test_help.activity.Login_activity$2.onClick(Login_activity.java:74)

下面是自己写的

    httpPost.setEntity(new UrlEncodedFormEntity(params, HTTP.UTF_8));
    HttpResponse httpResp = new DefaultHttpClient().execute(httpPost);

按照百度的神奇方法 在 onCreate方法里面

  StrictMode.setThreadPolicy(new StrictMode.ThreadPolicy.Builder()      
        .detectDiskReads()       
        .detectDiskWrites()       
        .detectNetwork()          
        .penaltyLog()       
        .build());       
         StrictMode.setVmPolicy(new StrictMode.VmPolicy.Builder()       
                .detectLeakedSqlLiteObjects()    
                .penaltyLog()       
                .penaltyDeath()       
                .build());  

据说包治网络异常

上面这段代码的作用是干啥子来着

我查了下 意识是严苛模式的线程策略和虚拟机策略

谁能简单说下 这个玩意为什么在这里能起作用?

阿神
阿神

闭关修行中......

reply all(1)
黄舟

= = Speechless 2333333
By the way, take a screenshot of the red exception information in Logcat, or Login_activity.java: line 74, which sentence is this?
Cover for network anomalies, 66666666

UPDATE
The questioner asked this kind of question, but he didn’t even give a complete picture...
Just give two sentences of exception information and two sentences of code. Who knows how you wrote it? , who knows how you went wrong?
Who knows if you just have a null pointer.
Simply.

There are basically so many network anomalies, you can look for them yourself.

As for the harsh mode, it’s better to delete it as soon as possible and forget about it.
If you want to write quality code. . .

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template