当我尝试在Android中下载网站源代码时遇到问题。
EditText textbox = (EditText) findViewById(R.id.editText1);
URL link;
HttpURLConnection httpcon;
String wynik;
try
{
link = new URL("http://stackoverflow.com/faq"); //example site
httpcon = (HttpURLConnection) link.openConnection();
httpcon.connect();
InputStream inpText = null;
inpText = link.openStream();
byte[] bText = new byte[httpcon.getContentLength()];
int readSize = inpText.read(bText);
wynik = new String(bText);
httpcon.disconnect();
inpText.close();
textbox.append(wynik);
}
catch(Exception e)
{
//
}
当我在AVD 2.2上运行此代码时,文本框包含所有网站源代码,但是当我在Android 2.3.5(或ADV 2.3.3)的手机上运行此文本框时,文本框只包含几行。
看起来完全像这样:
我的手机= 1012字节:
<title>Frequently Asked Questions - Stack Overflow</title>
<link rel="shortcut icon" href="http://cdn.sstatic.net/stackoverflow/img/favicon.ico">
<link rel="apple-touch-icon" href="http://cdn.sstatic.net/stackoverflow/img/apple-touch-icon.png">
<link rel="search" type="application/opensearchdescription+xml" title="Stack Overflow" href="/opensearch.xml">
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script>
<script type="text/javascript" src="http://cdn.sstatic.net/js/stub.js?v=8a629d6e9fb6"></script>
<link rel="stylesheet" type="text/css" href="http://cdn.sstatic.net/stackoverflow/all.css?v=645537e2c00d">
<script src="http://cdn.sstatic.net/Js/help.js?v=fc9fb0517db2" type="text/javascript"></script>
<script type="text/javascript">
StackExchange.ready(function() {
StackExchange.help.init({ host: 'stackoverflow.com', bgColor: '#FFF', bg
ADV 2.2 = 50 984字节
我做错了什么?
提前谢谢你,对不起我的英语。 帕特里克