Wie kann ich den Thread dann stoppen?
public void ButtonCheckForUpdatesOnClicked(View view) {
Toast.makeText(CheckForUpdateActivity.this, "Clicked", Toast.LENGTH_SHORT).show();
try {
checker.start();
} catch (Exception e){
System.out.println("Checker already running");
}
@Override
public void onDestroy() {
super.onDestroy();
Debug.stopMethodTracing();
checker.stop();
}
}
public class UpdateChecker extends Thread {
@Override
public void run(){
try {
String url = "";
String newversion = null;
URL filesFeed = new URL(url);
InputStream input = filesFeed.openConnection().getInputStream(); //absturz hier
Document document = DocumentBuilderFactory.newInstance().newDocumentBuilder().parse(input);
Node latesFile = document.getElementsByTagName("item").item(0);
NodeList children = latesFile.getChildNodes();
newversion = children.item(1).getTextContent();
if ("Beta_1.0" != newversion) {
System.out.println("Updates Found! New Version: " + newversion);
} else {
System.out.println("Your App is up to date!");
}
} catch (Exception e) {
if (e instanceof UnknownHostException)
System.out.println("Checking for updates FAILED! - Please check your internet connection!");
if (e instanceof MalformedURLException) System.out.println("MalformedURLException");
if (e instanceof IOException) System.out.println("IOException");
if (e instanceof ParserConfigurationException)
System.out.println("ParserConfigurationException");
if (e instanceof SAXException) System.out.println("SAXException");
else {
System.out.println("Checking for updates FAILED!" + e);
e.printStackTrace();
}
}
}
}
— geändert am 05.05.2016, 22:40:56
Empfohlener redaktioneller Inhalt
Mit Deiner Zustimmung wird hier ein externer Inhalt geladen.
Mit Klick auf den oben stehenden Button erklärst Du Dich damit einverstanden, dass Dir externe Inhalte angezeigt werden dürfen. Dabei können personenbezogene Daten an Drittanbieter übermittelt werden. Mehr Infos dazu findest Du in unserer Datenschutzerklärung.