{"id":7074,"date":"2014-05-19T04:12:14","date_gmt":"2014-05-19T04:12:14","guid":{"rendered":"https:\/\/unknownerror.org\/index.php\/2014\/05\/19\/android-open-a-remote-pdf-from-server-using-a-php-function-starts-download-but-fails-once-started-collection-of-common-programming-errors\/"},"modified":"2014-05-19T04:12:14","modified_gmt":"2014-05-19T04:12:14","slug":"android-open-a-remote-pdf-from-server-using-a-php-function-starts-download-but-fails-once-started-collection-of-common-programming-errors","status":"publish","type":"post","link":"https:\/\/unknownerror.org\/index.php\/2014\/05\/19\/android-open-a-remote-pdf-from-server-using-a-php-function-starts-download-but-fails-once-started-collection-of-common-programming-errors\/","title":{"rendered":"Android : Open a remote pdf from server using a php function starts download but fails once started-Collection of common programming errors"},"content":{"rendered":"<p>I have been struggling with this for quite some time, I have done my research and find the only answers are for native android builds, what I&#8217;m doing now is a little more convoluted.<\/p>\n<p>I was give a blackberry application written by Mr.X and was asked to port it to Android, I have done so and the majority of the application is working flawlessly &#8211; right up until the point where it has to open a remote file (pdf) from a server running php functions.<\/p>\n<p>To give an example :<\/p>\n<pre><code>var auth = make_base_auth(username, password);\n\nvar xmlhttp = new XMLHttpRequest();\nxmlhttp.open(\"GET\", baseURL + \"\/api\/streampdf.php?pdf=\"+name, true);\nxmlhttp.onreadystatechange = function() {\n if (xmlhttp.readyState == 4 &amp;&amp; xmlhttp.status == 200)\n {\n    alert(xmlhttp.responseText);\n    window.location.href = xmlhttp.responseText;      \n }\n}\n<\/code><\/pre>\n<p>This opens the default browser and gives the response text from the XMLHTTP and says the service is temporarily unavailable.<\/p>\n<p>I cant seem to figure this out !<\/p>\n","protected":false},"excerpt":{"rendered":"<p>I have been struggling with this for quite some time, I have done my research and find the only answers are for native android builds, what I&#8217;m doing now is a little more convoluted. I was give a blackberry application written by Mr.X and was asked to port it to Android, I have done so [&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-7074","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/7074","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=7074"}],"version-history":[{"count":0,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/7074\/revisions"}],"wp:attachment":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/media?parent=7074"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/categories?post=7074"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/tags?post=7074"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}