Android 如何使用“确定”按钮显示下载完整弹出窗口
我在Android Studio中使用webView制作了应用程序,我的应用程序包含所有图像,因此我在应用程序中也实现了下载按钮,但当有人单击下载按钮时,它只是下载图像,我想在下载完成时显示弹出窗口,类似这样的情况, 下载完成并在“确定”按钮下方 这是我的下载代码Android 如何使用“确定”按钮显示下载完整弹出窗口,android,android-studio,download,download-manager,Android,Android Studio,Download,Download Manager,我在Android Studio中使用webView制作了应用程序,我的应用程序包含所有图像,因此我在应用程序中也实现了下载按钮,但当有人单击下载按钮时,它只是下载图像,我想在下载完成时显示弹出窗口,类似这样的情况, 下载完成并在“确定”按钮下方 这是我的下载代码 Uri source = Uri.parse(url); // Make a new request pointing to the .apk url Download
Uri source = Uri.parse(url);
// Make a new request pointing to the .apk url
DownloadManager.Request request = new DownloadManager.Request(source);
// appears the same in Notification bar while downloading
request.setDescription("Description for the DownloadManager Bar");
request.setTitle("PunjabiDharti.jpg");
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
request.allowScanningByMediaScanner();
request.setNotificationVisibility(DownloadManager.Request.VISIBILITY_VISIBLE_NOTIFY_COMPLETED);
}
// save the file in the "Downloads" folder of SDCARD
request.setDestinationInExternalPublicDir(Environment.DIRECTORY_DOWNLOADS, "PunjabiDharti.jpg");
// get download service and enqueue file
DownloadManager manager = (DownloadManager) getSystemService(Context.DOWNLOAD_SERVICE);
manager.enqueue(request);
如何显示弹出窗口?首先,在build.gradle中添加MaterialDialog的依赖项 创建广播接收器处理程序 现在注册接收机
谢谢先生,它的作品:XD现在我可以显示插页广告后点击确定?
dependencies {
// ... other dependencies here
implementation 'com.afollestad.material-dialogs:core:0.9.6.0'
}
BroadcastReceiver downloadListener = new BroadcastReceiver(){
public void onReceive(Context ct, Intent intent){
new MaterialDialog.Builder(this)
.title("Download Completed")
.content("Download Successfully Completed")
.positiveText("OK")
.show();
}
};
registerReceiver(downloadListener, new IntentFilter(DownloadManager.ACTION_DOWNLOAD_COMPLETE));