Android应用程序无法识别setRedirectStrategy? [英] Android app not recognizing setRedirectStrategy?

查看:330
本文介绍了Android应用程序无法识别setRedirectStrategy?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想写与Apache的HttpClient库Android应用程序,尽管这code段编译的时候它是在一个实际的Java项目,它有错误的方法setRedirectStrategy(新DefaultRedirectStrategy(){})是未定义的类型DefaultHttpClient当我把它变成一个Android应用程序。有谁知道原因?

  DefaultHttpClient的HttpClient =新DefaultHttpClient();
        httpclient.setRedirectStrategy(新DefaultRedirectStrategy(){
 

解决方案

RedirectStrategy 中引入了<一href="http://hc.apache.org/httpcomponents-client-ga/httpclient/apidocs/org/apache/http/impl/client/AbstractHttpClient.html#setRedirectStrategy%28org.apache.http.client.RedirectStrategy%29"相对=nofollow> 4.1 。安卓(显然)<一href="http://stackoverflow.com/questions/2618573/what-version-of-apache-http-client-is-bundled-in-android-1-6">has一个版本更接近4.0 。

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() {  

解决方案

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

这篇关于Android应用程序无法识别setRedirectStrategy?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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