Android : Open a remote pdf from server using a php function starts download but fails once started-Collection of common programming errors

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’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 and the majority of the application is working flawlessly – right up until the point where it has to open a remote file (pdf) from a server running php functions.

To give an example :

var auth = make_base_auth(username, password);

var xmlhttp = new XMLHttpRequest();
xmlhttp.open("GET", baseURL + "/api/streampdf.php?pdf="+name, true);
xmlhttp.onreadystatechange = function() {
 if (xmlhttp.readyState == 4 && xmlhttp.status == 200)
 {
    alert(xmlhttp.responseText);
    window.location.href = xmlhttp.responseText;      
 }
}

This opens the default browser and gives the response text from the XMLHTTP and says the service is temporarily unavailable.

I cant seem to figure this out !