Android 从网页安装apk
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/2328459/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
apk installation from web page
提问by Arutha
I'm looking for a sample web page (html code) with a link that will install an apk file directly on my phone by clicking on the link.
我正在寻找带有链接的示例网页(html 代码),该链接将通过单击链接直接在我的手机上安装 apk 文件。
采纳答案by Mark B
Just link to the apk file in the HTML. It couldn't be any simpler.
只需链接到 HTML 中的 apk 文件即可。再简单不过了。
<a href="path to my .apk file">link</a>
You will have to have "install apps from unknown sources" enabled on your phone.
您必须在手机上启用“安装来自未知来源的应用程序”。
回答by Richard C
If you're using ASP.NET, then you'll need to insert the following in your web.config file:
如果您使用的是 ASP.NET,则需要在 web.config 文件中插入以下内容:
<configuration>
...
<system.webServer>
<staticContent>
<mimeMap fileExtension=".apk"
mimeType="application/vnd.android.package-archive" />
</staticContent>
</system.webServer>
...
</configuration>
Apart from that (as others have said), you just need a normal link:
除此之外(正如其他人所说),您只需要一个普通链接:
<a href="myAndroidApp.apk">Click here</a>
and tell your users to enable the Security -> Unknown sources option in Settings.
并告诉您的用户在“设置”中启用“安全”->“未知来源”选项。
回答by Greg
Extra help for IIS webservers: mbaird's example worked great for me after I added the apk mime type to my IIS webserver. I just put an html file up with that link, but got a 404 error when trying to pull up my test.apk file without the .apk mime entry. As Commonsware said, make sure to allow .apk files in the mime types - this is for sure still necessary on an IIS webserver. You can do this from IIS Manager, select the server, and find "Mime Types", then add an entry.
IIS 网络服务器的额外帮助:在我将 apk mime 类型添加到我的 IIS 网络服务器后,maird 的示例对我来说非常有用。我只是将一个带有该链接的 html 文件放在一起,但是在尝试拉出我的 test.apk 文件而没有 .apk mime 条目时出现了 404 错误。正如 Commonsware 所说,确保允许使用 mime 类型的 .apk 文件 - 这在 IIS 网络服务器上肯定仍然是必要的。您可以从 IIS 管理器执行此操作,选择服务器,然后找到“Mime 类型”,然后添加一个条目。
回答by dean
In .Net this is what I did, I created an .asmx
page then a QR code that pointed to it
other wise I kept getting a 404, then this on page load.
在 .Net 这就是我所做的,我创建了一个.asmx
页面,然后创建了一个指向它的二维码,否则我一直收到 404,然后在页面加载时出现。
protected void Page_Load(object sender, EventArgs e){
ViewState["PreviousPage"] = Request.UrlReferrer;
string filepath = Server.MapPath("AcsMainMenu.apk");
FileInfo droidfile = new FileInfo(filepath);
if (droidfile.Exists)
{
Response.ClearContent();
Response.AddHeader("Content-Disposition", "attachment; filename=" + droidfile.Name);
Response.AddHeader("Content-Length", droidfile.Length.ToString());
Response.ContentType = "application/vnd.android.package-archive";
Response.TransmitFile(droidfile.FullName);
Response.Flush();
Response.End();
Response.Redirect(ViewState["PreviousPage"].ToString());
}
}