can you help me?
This is the code:
Using java Syntax Highlighting
- package Oroscopo.grg;
- import java.io.IOException;
- import java.io.InputStream;
- import java.io.InputStreamReader;
- import java.net.HttpURLConnection;
- import java.net.URL;
- import java.net.URLConnection;
- import android.app.ProgressDialog;
- import android.app.Activity;
- import android.graphics.Bitmap;
- import android.graphics.BitmapFactory;
- import android.os.Bundle;
- import android.widget.ImageView;
- import android.widget.TextView;
- public class arietesett extends Activity {
- /** Called when the activity is first created. */
- protected ProgressDialog myProgressDialog;
- @Override
- public void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- setContentView(R.layout.fuocosett);
- /* Show a progress-bar */
- myProgressDialog = ProgressDialog.show(arietesett.this,
- "Please wait...", "Doing Extreme Calculations...", true);
- new Thread() {
- public void run() {
- Bitmap bitmap =
- DownloadImage("http://www.moongate.it/oroscopo/arietesett.png");
- ImageView img = (ImageView) findViewById(R.id.img);
- img.setImageBitmap(bitmap);
- Bitmap bitmap1 =
- DownloadImage1("http://www.moongate.it/oroscopo/arietetext.png");
- ImageView imgt = (ImageView) findViewById(R.id.imgt);
- imgt.setImageBitmap(bitmap1);
- /*String str =
- DownloadText("http://www.moongate.it/oroscopo/ariete.txt");
- TextView txt = (TextView) findViewById(R.id.text);
- txt.setText(str);
- */
- String str1 =
- DownloadText1("http://www.moongate.it/oroscopo/data.txt");
- TextView txt1 = (TextView) findViewById(R.id.data);
- txt1.setText(str1);
- }
- };
- }
- private InputStream OpenHttpConnection(String urlString)
- throws IOException
- {
- InputStream in = null;
- int response = -1;
- URL url = new URL(urlString);
- URLConnection conn = url.openConnection();
- if (!(conn instanceof HttpURLConnection))
- throw new IOException("Not an HTTP connection");
- try{
- HttpURLConnection httpConn = (HttpURLConnection) conn;
- httpConn.setAllowUserInteraction(false);
- httpConn.setInstanceFollowRedirects(true);
- httpConn.setRequestMethod("GET");
- httpConn.connect();
- response = httpConn.getResponseCode();
- if (response == HttpURLConnection.HTTP_OK) {
- in = httpConn.getInputStream();
- }
- }
- catch (Exception ex)
- {
- throw new IOException("Error connecting");
- }
- return in;
- }
- private Bitmap DownloadImage(String URL)
- {
- Bitmap bitmap = null;
- InputStream in = null;
- try {
- in = OpenHttpConnection(URL);
- bitmap = BitmapFactory.decodeStream(in);
- in.close();
- } catch (IOException e1) {
- // TODO Auto-generated catch block
- e1.printStackTrace();
- }
- return bitmap;
- }
- private Bitmap DownloadImage1(String URL)
- {
- Bitmap bitmap = null;
- InputStream in = null;
- try {
- in = OpenHttpConnection(URL);
- bitmap = BitmapFactory.decodeStream(in);
- in.close();
- } catch (IOException e1) {
- // TODO Auto-generated catch block
- e1.printStackTrace();
- }
- return bitmap;
- }
- /*private String DownloadText(String URL)
- {
- int BUFFER_SIZE = 2000;
- InputStream in = null;
- try {
- in = OpenHttpConnection(URL);
- } catch (IOException e1) {
- // TODO Auto-generated catch block
- e1.printStackTrace();
- return "";
- }
- InputStreamReader isr = new InputStreamReader(in);
- int charRead;
- String str = "";
- char[] inputBuffer = new char[BUFFER_SIZE];
- try {
- while ((charRead = isr.read(inputBuffer))>0)
- {
- //---convert the chars to a String---
- String readString =
- String.copyValueOf(inputBuffer, 0, charRead);
- str += readString;
- inputBuffer = new char[BUFFER_SIZE];
- }
- in.close();
- } catch (IOException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- return "";
- }
- return str;
- } */
- private String DownloadText1(String URL)
- {
- int BUFFER_SIZE = 2000;
- InputStream in = null;
- try {
- in = OpenHttpConnection(URL);
- } catch (IOException e1) {
- // TODO Auto-generated catch block
- e1.printStackTrace();
- return "";
- }
- InputStreamReader isr = new InputStreamReader(in);
- int charRead;
- String str1 = "";
- char[] inputBuffer = new char[BUFFER_SIZE];
- try {
- while ((charRead = isr.read(inputBuffer))>0)
- {
- //---convert the chars to a String---
- String readString =
- String.copyValueOf(inputBuffer, 0, charRead);
- str1 += readString;
- inputBuffer = new char[BUFFER_SIZE];
- }
- in.close();
- } catch (IOException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- return "";
- }
- return str1;
- }
- }
Parsed in 0.051 seconds, using GeSHi 1.0.8.4


