我正在写一个网站,当有人访问链接时,它会自动提供APK下载"http://www.sample-link.com/download/downloadApp这是我在PHP网站上的代码。
$fileName = "./uploads/MyAPK.apk";
header('Content-type: application/download');
header('Content-Disposition: attachment; fileName="' . basename($fileName) . '"');
header('Content-Transfer-Encoding: binary');
readfile($fileName);
当我在PC上访问该链接时,它会工作。当我在安卓设备上下载时,无法完成下载。它卡在下载队列中,错误为"无法下载。不支持内容"。我试图重新启动设备,但它不起作用。如何修复?
使用application/vnd.android.package-archive
作为apk的内容类型。
参考:维基百科