{"id":5299,"date":"2014-03-30T20:31:29","date_gmt":"2014-03-30T20:31:29","guid":{"rendered":"https:\/\/unknownerror.org\/index.php\/2014\/03\/30\/how-to-correctly-use-parameters-passed-to-a-an-android-thread-collection-of-common-programming-errors\/"},"modified":"2014-03-30T20:31:29","modified_gmt":"2014-03-30T20:31:29","slug":"how-to-correctly-use-parameters-passed-to-a-an-android-thread-collection-of-common-programming-errors","status":"publish","type":"post","link":"https:\/\/unknownerror.org\/index.php\/2014\/03\/30\/how-to-correctly-use-parameters-passed-to-a-an-android-thread-collection-of-common-programming-errors\/","title":{"rendered":"How to correctly use parameters passed to a an android thread?-Collection of common programming errors"},"content":{"rendered":"<p>I have an external .hash file which I tired reading as a simple remote text file:<\/p>\n<pre><code>private class getHash extends AsyncTask{\n    @Override\n    protected String doInBackground(String... params) {\n        String str = null;\n        try {\n            \/\/ Create a URL for the desired page\n            URL url = new URL(params[0]);\n\n            \/\/ Read all the text returned by the server\n            InputStream is =  url.openStream();\/\/The line it crashes on\n            InputStreamReader isr = new InputStreamReader(is);\n            BufferedReader in = new BufferedReader(isr);\n            str = in.readLine();\n            in.close();\n        } catch (MalformedURLException e) {\n            e.printStackTrace();\n        } catch (IOException e) {\n            e.printStackTrace();\n        }\n        return str;\n    }\n    @Override\n    protected void onPostExecute(String result) {\n        hash = result;\n    }\n}\n<\/code><\/pre>\n<p>Then I call the thread :<\/p>\n<pre><code>getHash hashThread =  new getHash();\nhashThread.execute(new String[]{\"http:\/\/www......................hash\"});\n<\/code><\/pre>\n<p>During execution of the noted line in the class all stops are pulled and I get slapped by the classy <code>Source not found<\/code> crash.<\/p>\n<p>LogCat gives this error:<\/p>\n<pre><code>W\/dalvikvm(724): threadid=1: thread exiting with uncaught exception (group=0x40a13300)\n<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>I have an external .hash file which I tired reading as a simple remote text file: private class getHash extends AsyncTask{ @Override protected String doInBackground(String&#8230; params) { String str = null; try { \/\/ Create a URL for the desired page URL url = new URL(params[0]); \/\/ Read all the text returned by the server [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-5299","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/5299","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/comments?post=5299"}],"version-history":[{"count":0,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/5299\/revisions"}],"wp:attachment":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/media?parent=5299"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/categories?post=5299"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/tags?post=5299"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}