Don't say much nonsense, directly on the source
the last webpage source code in the result.
Public voidbtn (view view) {NewMyworker (). Execute ("Here's the URL"); }
An asynchronous operation that prevents the UI thread from blocking. Private classMyworkerextendsAsynctask<string,void,string>
{ protectedString Doinbackground (string...urls) {StringBuilder builder=NewStringBuilder (100000); for(String url:urls) {
Defaulthttpclient Client=Newdefaulthttpclient ();
HttpGet HttpGet=Newhttpget (URL); Try{HttpResponse Execute=Client.execute (HttpGet);
InputStream content=execute.getentity (). getcontent (); BufferedReader Buffer=NewBufferedReader (NewInputStreamReader (content)); String s= ""; while((s = buffer.readline ())! =NULL) {builder.append (s); } } Catch(Exception e) {e.printstacktrace (); } } returnbuilder.tostring (); } protected voidOnPostExecute (String result) {
Source code displayed in TextView TextView TextView=(TextView) Findviewbyid (R.ID.TV1); Textview.settext (result); Get Source}}
Get results
Android "Shanxi illegal query Implementation 2" (parse the Web source and then the ListView display)---the client to obtain HTML source code