Reputation: 3256
I have a pretty simple question but somehow not able to find a solution on stackoverflow.
I am able to start the downloading of file from WebView
and also able to listen to Broadcast
after download completes. Here is the relevant code
aWebView.setDownloadListener(new DownloadListener() {
public void onDownloadStart(String url, String userAgent,
String contentDisposition, String mimetype,
long contentLength) {
// Intent i = new Intent(Intent.ACTION_VIEW);
// i.setData(Uri.parse(url));
// startActivity(i);
final String fileName = URLUtil.guessFileName(url,contentDisposition,mimetype);
Request request = new Request(
Uri.parse(url));
request.allowScanningByMediaScanner();
request.setNotificationVisibility(DownloadManager.Request.VISIBILITY_VISIBLE_NOTIFY_COMPLETED);
request.setDestinationInExternalPublicDir(Environment.DIRECTORY_DOWNLOADS, fileName);
DownloadManager dm = (DownloadManager) getSystemService(DOWNLOAD_SERVICE);
dm.enqueue(request);
}
});
Now what I need to know is, any way we can popup the app Install/Cancel
dialog programmatically for that particular downloaded app ?
Upvotes: 0
Views: 662
Reputation: 7292
You can try this:
String filePath = "Your file path";
Intent intent = new Intent(Intent.ACTION_VIEW);
intent.setDataAndType(Uri.fromFile(new File(filePath)),"application/vnd.android.package-archive");
startActivity(intent);
The situation is something special as you use for the .apk file downloaded from your app?
Upvotes: 1