HTTP GET在异步任务不工作 [英] HTTP GET in async task does not work

查看:145
本文介绍了HTTP GET在异步任务不工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我从一个HTTPPOST的响应,采取从它的子串是URL,然后做一个HTTPGET就可以了,我无法得到任何回应。什么问题可以是任何投入?

 字符串pkmspogout1 = result.substring(result.indexOf()+ 1,result.length());
                        Log.i(Lpkmspogout1,pkmspogout1);
                    HttpClient的httpclient4 =新DefaultHttpClient();                    HTT presponse logoutresponse;
                    尝试{
                        HTTPGET HTTPGET =新HTTPGET(pkmspogout1);                        logoutresponse = httpclient4.execute(HTTPGET);
                        的BufferedReader IN2 =新的BufferedReader(新的InputStreamReader(logoutresponse.getEntity()的getContent()));                        StringBuffer的SB2 =新的StringBuffer();                        2号线的String =;
                        串NL2 = System.getProperty(line.separator);
                         而((2号线= in2.readLine())!= NULL){
                            sb2.append(行+ NL2);                        }
                        in2.close();
                        串pkmslogout5 = sb2.toString();
                        Log.i(从PKMS logoutresponse,pkmslogout5 +);
                    }赶上(例外五){}


解决方案

据工作终于,呼!我试过(pkmspogout1.trim())和它的工作! (前,在URL后空间是问题)。

I get a response from a HTTPPOST, take a substring from it which is URL and then do a HTTPGET on it, I am unable to get any response. Any inputs on what the issue could be?

 String pkmspogout1 = result.substring(result.indexOf(",")+1,result.length());
                        Log.i("Lpkmspogout1 ", pkmspogout1);


                    HttpClient httpclient4 = new DefaultHttpClient();

                    HttpResponse logoutresponse  ;
                    try {
                        HttpGet httpget = new HttpGet(pkmspogout1);

                        logoutresponse = httpclient4.execute(httpget);
                        BufferedReader in2 = new BufferedReader(new InputStreamReader(logoutresponse.getEntity().getContent()));

                        StringBuffer sb2 = new StringBuffer("");

                        String line2 = "";
                        String NL2 = System.getProperty("line.separator");
                         while ((line2 = in2.readLine()) != null) {
                            sb2.append(line + NL2);

                        }
                        in2.close();


                        String pkmslogout5 = sb2.toString();
                        Log.i("logoutresponse from pkms", pkmslogout5+"");
                    } catch (Exception e) {}

解决方案

It is working finally, Phew !I tried (pkmspogout1.trim()) and it worked ! (spaces before and after the URL were the issue).

这篇关于HTTP GET在异步任务不工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆