View difference between Paste ID: FJyWhVrL and zkskusVi
SHOW: | | - or go back to the newest paste.
1-
package finnq.de.cm9.downloads;
1+
package mypage.de.downloads;
2
3
4
import java.io.BufferedReader;
5
import java.io.IOException;
6
import java.io.InputStreamReader;
7
8
import org.apache.http.HttpResponse;
9
import org.apache.http.client.ClientProtocolException;
10
import org.apache.http.client.HttpClient;
11
import org.apache.http.client.methods.HttpGet;
12
import org.apache.http.impl.client.DefaultHttpClient;
13
import org.apache.http.protocol.BasicHttpContext;
14
import org.apache.http.protocol.HttpContext;
15
16
import android.app.Activity;
17
import android.os.Bundle;
18
import android.view.View;
19
import android.view.View.OnClickListener;
20
import android.widget.Button;
21
import android.widget.Toast;
22
23-
public class CM9DownloadsActivity extends Activity {
23+
public class DownloadsActivity extends Activity {
24
    /** Called when the activity is first created. */
25
    @Override
26
    public void onCreate(Bundle savedInstanceState) {
27
        super.onCreate(savedInstanceState);
28
        setContentView(R.layout.main);
29
        Button button = (Button) findViewById(R.id.button_hi);
30
        button.setOnClickListener(new OnClickListener() {
31
           public void onClick(View v) {
32
        	getHtml();
33
           }
34
        });
35
    }
36
    public void getHtml() throws ClientProtocolException, IOException
37
    {
38
        HttpClient httpClient = new DefaultHttpClient();
39
        HttpContext localContext = new BasicHttpContext();
40
        HttpGet httpGet = new HttpGet("http://www.spartanjava.com");
41
        HttpResponse response = httpClient.execute(httpGet, localContext);
42
        String result = "";
43
44
        BufferedReader reader = new BufferedReader(
45
            new InputStreamReader(
46
              response.getEntity().getContent()
47
            )
48
          );
49
50
        String line = null;
51
        while ((line = reader.readLine()) != null){
52
          result += line + "\n";
53-
          Toast.makeText(CM9DownloadsActivity.this, line.toString(), Toast.LENGTH_LONG).show();
53+
          Toast.makeText(DownloadsActivity.this, line.toString(), Toast.LENGTH_LONG).show();
54
55
        }
56
57
    }
58
59
}