I'm trying to download an apk file from server via DownloadManager:
dm = (DownloadManager) getSystemService(DOWNLOAD_SERVICE);
DownloadManager.Request request = new DownloadManager.Request(Uri.parse(url));
request.setMimeType("application/vnd.android.package-archive");
request.allowScanningByMediaScanner();
enqueue = dm.enqueue(request);
When the apk is downloaded and I press it I'm getting "can't open file message",
But if I download that apk via Browser instead of DownloadManger:
Intent browserIntent = new Intent(Intent.ACTION_VIEW, Uri.parse(url));
startActivity(browserIntent);
The apk works fine.
The device is open for "Unknown sources" and it's version is 4.1.2
What am I doing wrong?
try saving the apk file to your local storage and then opening it using a direct file URI