开发者

download apk from own Webserver

开发者 https://www.devze.com 2023-01-15 03:45 出处:网络
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

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.

download apk from own Webserver

When I use Firefox to download my app, Firefox successfully download it with correct name and size.

download apk from own Webserver

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.


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


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

AddType application/vnd.android.package-archive .apk
0

精彩评论

暂无评论...
验证码 换一张
取 消