[Android] 使用HttpGet加上基本驗證時,得到回應400 Bad Request
在Android的開發上,搭配Restful Service去取得資料時,通常會使用HttpClient加上HttpGet去向Server抓取資料來源,例如說下面這樣 try { HttpResponse response = client.execute(get); StatusLine statusLine = response.getStatusLine(); if(statusLine.getStatusCode() == HttpStatus.SC_OK){ HttpEntity entity = response.getEntity(); ByteArrayOutputStream out = new ByteArrayOutputStream(); entity.writeTo(out); ...