1

I am trying to write an android app with apache's httpclient library, and although this code snippet compiles when it is in a actual Java project, it has the error The method setRedirectStrategy(new DefaultRedirectStrategy(){}) is undefined for the type DefaultHttpClient when I put it into an android app. Does anybody know the reason?

DefaultHttpClient httpclient = new DefaultHttpClient();
        httpclient.setRedirectStrategy(new DefaultRedirectStrategy() {  
Elias Wu
  • 71
  • 7

1 Answers1

0

The RedirectStrategy was introduced with 4.1. Android (apparently) has a version closer to 4.0.

Community
  • 1
  • 1
dmon
  • 30,048
  • 8
  • 87
  • 96
  • In this case, you can't override the system (Android's) implementation, DEX will complain and proguard will probably just ignore those classes (or fail) anyway. – dmon Feb 13 '12 at 03:41
  • You can use a `RedirectHandler` though. – dmon Feb 13 '12 at 03:41
  • wait how would i use RedirectHandler? httpclient.RedirectHandler? – Elias Wu Feb 13 '12 at 03:53
  • Hmm apparently Android doesn't support RedirectHandler (?). See http://blog.kosev.net/2011/01/follow-302-redirects-with.html. – dmon Feb 13 '12 at 04:04