简体   繁体   English

从服务器下载文件 apk 并安装

[英]Download file apk from server and install it

I have feature check newest version the application, if current version is lesser than version in server it will show dialog to update the application like this.我有功能检查应用程序的最新版本,如果当前版本低于服务器中的版本,它将显示对话框以像这样更新应用程序。

in above update, if i click copy link and download , it will copy url and open the browser,after that download.apk from url server i already setting.在上面的更新中,如果我点击复制链接并下载,它将复制 url 并打开浏览器,然后从我已经设置的 url 服务器下载.apk。

it's work, but i want make it more efficient.这是工作,但我想让它更有效率。 I want if i click the button, it will download.apk from server and show the progress download without open the browser.我希望如果我单击该按钮,它将从服务器下载.apk 并在不打开浏览器的情况下显示下载进度。 How can i do this?我怎样才能做到这一点?

Thank's谢谢

Play Store应用商店

It's not a feature currently available to my knowledge.据我所知,这不是目前可用的功能。 In apps I develop, I can check the version number and block the user from using the app via a dialog, but provide a link to the Play Store, so they can update to the latest version.在我开发的应用程序中,我可以检查版本号并通过对话框阻止用户使用该应用程序,但提供指向 Play 商店的链接,以便他们可以更新到最新版本。

However, Android 11 provides Inline Updates, which provides a more streamlined experience.但是,Android 11 提供了内联更新,提供了更流畅的体验。

Check out In-App Updates查看应用内更新

Android 11 as of this date is currently in preview. Android 截至此日期的 11 当前处于预览状态。 To use the APIs you will have to use a platform channel to call natively from Flutter.要使用 API,您必须使用平台通道从 Flutter 本地调用。

Side loading侧装

Check out Install Application programmatically on Android查看以编程方式在 Android 上安装应用程序

You will have to use http to download the APK to external storage, then call these APIs via a platform channel .您必须使用 http 将 APK 下载到外部存储,然后通过平台通道调用这些 API。

Yes you can make it to where when you click a button, a file (any format including APK) is downloaded to the Downloads/Files folder of the user's device.是的,您可以在单击按钮时将文件(包括 APK 在内的任何格式)下载到用户设备的“下载/文件”文件夹中。

However, it is something that is handled by the server that is storing the files.但是,它是由存储文件的服务器处理的。

For example, if you tap on this link , it will automatically download a PDF file on your Android phone or on your browser, even if PDFs generally open inside your browser.例如,如果您点击此链接,它会自动在您的 Android 手机或浏览器上下载 PDF 文件,即使 PDF 通常在您的浏览器中打开也是如此。

There is a few suggestions given here on how to do it, including setting "Content-Disposition: attachment" or "Content-Type: application/octet-stream" 这里给出了一些关于如何做的建议,包括设置“Content-Disposition: attachment”或“Content-Type: application/octet-stream”

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

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