简体   繁体   English

在手机上自动下载并打开.APK文件

[英]Download and open .APK file automatically on Mobile

I have a button in my Native App(Cordova) : 我的Native App(Cordova)中有一个按钮:

<li><a href="myapp.apk" download="myapp.apk">Download</a></li>

The button download is not working on mobile... And I would like, when download's finished, that the apk file opens automatically. 按钮下载在移动设备上不起作用...而且我希望下载完成后,apk文件会自动打开。

Problem seems like in your path. 问题似乎在您的道路上。 If you have the apk stored in somewhere in server, you can provide the path of the file. 如果您将apk存储在服务器中的某个位置,则可以提供文件的路径。 For example 例如

 <a href="http://www.thegadgettechie.com/wp-content/uploads/2016/08/hello-1.jpg" download="hello">Download link</a> 

This will download the image specified in href tag. 这将下载href标签中指定的图像。 Make sure your url starts with 'http'. 确保您的网址以“ http”开头。 If you didn't specify a path which didn't start with http, cordova will look for the file with respect to the root folder (where your index.html is located). 如果您未指定不是以http开头的路径,那么cordova会根据根文件夹(您的index.html所在的位置)查找文件。

So if you simply specify 因此,如果您仅指定

  <a href="myApp.apk" download="myApp">Download link</a> 

This will look for the file myApp.apk inside the root folder of your app. 这将在应用程序的根文件夹中查找文件myApp.apk。 The above code will work if your myApp.apk is indside your www folder. 如果myApp.apk位于www文件夹中,则以上代码将起作用。

www ---- index.html ---- myApp.apk ---- app.js

So based on the location of the file, you specify path. 因此,根据文件的位置,您可以指定路径。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM