我的应用程序在 2.2 中,但我希望它在 2.1 中。我进行了目标更改,但这里出现错误:
import android.net.http.AndroidHttpClient;
因为我读过它仅在 2.2 及更高版本中受支持。所以我做了以下替换:
import org.apache.http.client.HttpClient;
但我在这里得到一个语法错误:
httpclient.close(); ## error states add cast
整个代码在这里:
public static HttpClient httpclient = null;
try {
URL aURL = new URL(url);
URLConnection conn = aURL.openConnection();
conn.connect();
InputStream is = conn.getInputStream();
BufferedInputStream bis = new BufferedInputStream(is);
bm = BitmapFactory.decodeStream(new FlushedInputStream(is));
bis.close();
is.close();
} catch (Exception e) {
e.printStackTrace();
} finally {
if (httpclient != null) {
httpclient.close();
}
}