This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
mHttpClient.setRedirectHandler(new DefaultRedirectHandler() { | |
@Override | |
public boolean isRedirectRequested(HttpResponse response, HttpContext context) { | |
boolean isRedirect = super.isRedirectRequested(response, context); | |
if (!isRedirect) { | |
int responseCode = response.getStatusLine().getStatusCode(); | |
if (responseCode == 301 || responseCode == 302) { | |
return true; | |
} | |
} | |
return isRedirect; | |
} | |
@Override | |
public URI getLocationURI(HttpResponse response, HttpContext context) throws ProtocolException { | |
int responseCode = response.getStatusLine().getStatusCode(); | |
if (responseCode == 301 || responseCode == 302) { | |
Log.l(response.getLastHeader("Location").getValue()); | |
String redirectStr = response.getLastHeader("Location").getValue(); | |
if (response.getLastHeader("Location").getValue().contains("#")) { | |
mIs302Redirection = true; | |
String[] redirectUrl = redirectStr.split("#"); | |
Log.l(redirectUrl[0]); | |
mAddResultData = redirectUrl[1]; | |
return URI.create(redirectUrl[0]); | |
} | |
} | |
return super.getLocationURI(response, context); | |
} | |
}); |
'Android' 카테고리의 다른 글
[android] adb shell 명령어 정리 (0) | 2017.06.07 |
---|---|
[android] JSONObject 형식의 String에 탭 넣기. _ Insert tab into JSONObject String (0) | 2017.05.04 |
[android] 안드로이드폰에서 파일 다운로드 시 WiFi에서만 받아지는 문제 해결방법 (0) | 2015.02.04 |
[android] 안드로이드폰 루팅 하기 / 루팅 해제하기 (금융권 앱 사용하기) (2) | 2015.02.02 |
[android]WebView에서 Webpage의 javascriptinterface가 동작하지 않을 때 해결방법 (0) | 2014.03.31 |