如何解决如何从android网址
请不要将其标记为重复...我指的是此答案-> https://stackoverflow.com/a/54986577/12553303
单击按钮没有任何反应...没有下载
download.setOnClickListener {
if (ActivityCompat.checkSelfPermission(applicationContext,Manifest.permission.READ_EXTERNAL_STORAGE) !== PackageManager.PERMISSION_GRANTED || ActivityCompat.checkSelfPermission(
applicationContext,Manifest.permission.WRITE_EXTERNAL_STORAGE) !== PackageManager.PERMISSION_GRANTED
) {
// this will request for permission when user has not granted permission for the app
ActivityCompat.requestPermissions(this@Product_details,arrayOf(Manifest.permission.READ_EXTERNAL_STORAGE,Manifest.permission.WRITE_EXTERNAL_STORAGE),1)
} else {
//Download Script
val downloadManager: DownloadManager = getSystemService(DOWNLOAD_SERVICE) as DownloadManager
val uri = Uri.parse(product_images)
val request: DownloadManager.Request = DownloadManager.Request(uri)
request.setVisibleInDownloadsUi(true)
Toast.makeText(
applicationContext,uri.toString(),Toast.LENGTH_LONG
).show()
request.setNotificationVisibility(DownloadManager.Request.VISIBILITY_VISIBLE_NOTIFY_COMPLETED)
request.setDestinationInExternalPublicDir(Environment.DIRECTORY_DOWNLOADS,uri.lastPathSegment)
downloadManager.enqueue(request)
}
}
其中product_image
==> val product_images:String =intent1.getStringExtra("image")
需要帮助谢谢
解决方法
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。