The code below works fine on desktop browsers (Chrome, FF), but when executed from a Android mobile (HTC Evo, Galaxy S) device the file is downloaded but empty. I've added the following line to my .htaccess file...
AddType application/vnd.android.package-archive .apk
... and the download works as expected if I link directly to the .apk from a HTML anchor.
I need to provide the download via a PHP script though so that I can update database records. The following PHP method even works as expected on a blackberry device:
public function download($file)
{
if (!is_readable($file)) {
return false;
}
header('Content-Type: application/vnd.android.package-archive');
header('Content-Disposition: attachment; filename="test.apk"');
header('Content-length: ' . filesize($file));
readfile($file);
return true;
}