Hallo guys, im here in austria how are you doing?
i have startet developing android and writing my own small app that gets files from a server to display the information in a ListView. I really spent a day to look after the best and easiest way to get files from a server. However i wrote the program and tested it - and now i have a serious error message when running the virtual htc machine.
Its called: The application org.me.newspuler (process org.me.newspuler) has stopped unexpectedly. Please try again.
Under this message is put a "Force Close" Button.
I really dont know how to get a hint to the problem, NewsPuler is my APP, - i think I need help from some more proffs
I have 2 classes - one for the download file(i think here is the mistake) - one for the Main Activity When the compiler comes to the point in the code where the instance from "DownloadFile" is created... the error appears.
the download file class:
package logik;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.ArrayList;
import java.util.logging.Level;
import java.util.logging.Logger;
/**
*
* @author raa
*/
public class DownloadFile {
InputStream is = null;
String link = null;
BufferedReader d = null;
URL url = null;
String s;
ArrayList<String> al = new ArrayList<String>();
public DownloadFile(String link) throws MalformedURLException{
this.link = link;
url = new URL(link);
try {
is = url.openStream();
} catch (IOException ex) {
Logger.getLogger(DownloadFile.class.getName()).log(Level.SEVERE, null, ex);
}
d = new BufferedReader(new InputStreamReader(is));
try {
while ((s = d.readLine()) != null) {
al.add(s);
}
} catch (IOException ex) {
Logger.getLogger(DownloadFile.class.getName()).log(Level.SEVERE, null, ex);
}
}
public ArrayList getArrayList(){
return al;
}
}
And here (it works correclty if you leave the commented code, but when you uncomment it - not)
package org.me.newspuler;
import logik.DownloadFile;
import android.app.Activity;
import android.os.Bundle;
import android.widget.ArrayAdapter;
import android.widget.ListView;
import java.net.MalformedURLException;
import java.util.ArrayList;
import java.util.logging.Level;
import java.util.logging.Logger;
/**
*
* @author raa
*/
public class MainActivity extends Activity {
ArrayList<String> al;
DownloadFile df;
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle icicle) {
super.onCreate(icicle);
ListView myListView = (ListView)findViewById(R.id.myListView);
// try {
// df = new DownloadFile("http://www.google.at/");
//
// } catch (MalformedURLException ex) {
// Logger.getLogger(MainActivity.class.getName()).log(Level.SEVERE, null, ex);
// }
// al.add("Test");
// final ArrayAdapter<String> aa = new ArrayAdapter<String>(this,
// android.R.layout.simple_list_item_1, al);
//
// myListView.setAdapter(aa);
}
}
I would be really glad to get some help! Kindly Regards from Austria.