2

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.

TS.xy
  • 1,244
  • 2
  • 13
  • 29
  • Examine your server logs and see what is going on. – CommonsWare Sep 09 '10 at 00:46
  • I doubt it's the problem but your – stealthcopter Sep 09 '10 at 01:31
  • Hi CommonsWare & stealthcopter, the java script worked fine, my android emualtor does open the download link, When I debug my server, it received the request, and did sent out the bytes of my application. – TS.xy Sep 09 '10 at 02:36

2 Answers2

3

Include a .htaccess in the folder or edit the existing file and add the line:

AddType application/vnd.android.package-archive .apk
Druid
  • 6,423
  • 4
  • 41
  • 56
3

Finally I got my problem solved.

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

But Android emulator sends 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
  • 1,244
  • 2
  • 13
  • 29
  • so how to start installing automatically? I mean i can download the apk file from my own server but i need to use an installer program (named astro) for installing. how to achieve to install automatically? – Mustafa Güven Dec 15 '11 at 17:15
  • 1
    An anonymous user asks (by incorrectly suggesting an edit) how you ignored the first attempt. Was it something you did in your apache conf file? Something in the code? They'd like to know the answer and think it would help others. If you agree and are willing, please consider updating your answer with this information. – Cody Gray - on strike Mar 20 '13 at 21:13