tags:

views:

88

answers:

1

Hi,

I am having problem with download my android application from my own web server.

First I sent a html content with java script to ask Android phone to open my download link

<html>
    <head>
        <script>
            window.onload=function()
            {{
                window.location = "downloadURL";
            }}
        </script>
    </head>
</html>"

Android phone revice this java script will open the downloadURL

On my server end, I am using .Net ASP

I've set up the MIME content

Response.Cache.SetCacheability(HttpCacheability.NoCache);
Response.ContentType = "application/vnd.android.package-archive";
Response.AppendHeader("Content-Disposition", "attachment; filename=" + "MyApp.apk");
Response.AppendHeader("Content-Length", "" + response.Application.Bytes.Length);
Response.BinaryWrite(response.Application.Bytes);

The apk file which is MyApp.apk is about 1.5MB

How ever, when I used Android emulator to download the app, the file size is only 4.25 KB, and the name is not MyApp.apk. It contains the name of my download link.

alt text

When I use Firefox to download my app, Firefox successfully download it with correct name and size. alt text Please help me out!! Thanks

When I debug my server, my server did sent out the application bytes with

Response.BinaryWrite(response.Application.Bytes);

I don't understand why, andorid emulator can not receive, intead it seems create its own apk file from the html content.

A: 

Finally I got my problem solved.

Becase Firefox sent one http request base on my download link.

But Android emulator send two http request base on my download link

I have to ignore the first request.

It took me few hours to figure it out.

Hope this information can help others

TS.xy