问题描述
我的某些用户导致了这次崩溃:
java.lang.ArithmeticException:
at de.xxx.lustigebildervideos.DownloadFile$downloadFile$1.invoke$lambda-1 (DownloadFile.java)
at de.xxx.lustigebildervideos.DownloadFile$downloadFile$1.lambda$Kbj3agXFd8IQFPtNa8sysNDFn20 (DownloadFile.java)
at de.xxx.lustigebildervideos.-$$Lambda$DownloadFile$downloadFile$1$Kbj3agXFd8IQFPtNa8sysNDFn20.run (lambda)
at java.lang.Thread.run (Thread.java:919)
我不知道问题是什么,因为一切对我来说都很好,所以我无法调试它。它似乎发生在这里的某个地方:
val request = DownloadManager.Request(Uri.parse("$fileURL&android=1"))
.setDestinationInExternalPublicDir(Environment.DIRECTORY_PICTURES,"/$path/$fileName")
val dm = getSystemService(Context.DOWNLOAD_SERVICE) as DownloadManager
downloadID = dm.enqueue(request)
val br = object:broadcastReceiver(){
override fun onReceive(p0: Context?,p1: Intent?) {
val id:Long? = p1?.getLongExtra(DownloadManager.EXTRA_DOWNLOAD_ID,-1)
if(id == downloadID){
downloadingOK = true
finish()
overridePendingTransition(0,0)
}
}
}
registerReceiver(br,IntentFilter(DownloadManager.ACTION_DOWNLOAD_COMPLETE))
Thread {
var downloading = true
while (downloading) {
val q = DownloadManager.Query()
q.setFilterById(downloadID)
val cursor: Cursor = dm.query(q)
cursor.movetoFirst()
val bytesDownloaded: Int = cursor.getInt(
cursor
.getColumnIndex(DownloadManager.COLUMN_BYTES_DOWNLOADED_SO_FAR)
)
val bytesTotal: Int =
cursor.getInt(cursor.getColumnIndex(DownloadManager.COLUMN_TOTAL_SIZE_BYTES))
if(cursor.getInt(cursor.getColumnIndex(DownloadManager.COLUMN_STATUS)) === DownloadManager.STATUS_SUCCESSFUL) {
downloading = false
}
val dlProgress = ((bytesDownloaded * 100L) / bytesTotal).toInt()
runOnUiThread {
dlProgressBar.progress = dlProgress
}
cursor.close()
}
}.start()
有什么问题吗?
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)