0

I try to identify Cancel button listener in system level generate notification by DownloadManager. But i am not getting that listener. Here is my code :

Thread {
    var complete: Boolean = true
    while (complete) {
    val cursor: Cursor? = downloadManager?.query(mQuery)
    if (cursor?.moveToFirst() == true) {
        val status: Int =
            cursor.getInt(cursor.getColumnIndex(DownloadManager.COLUMN_STATUS) ?: 0)

        val total: Long =
            cursor.getLong(
                cursor.getColumnIndex(DownloadManager.COLUMN_TOTAL_SIZE_BYTES) ?: 0
            )

        val downloaded: Long? =
            cursor.getLong(
                cursor.getColumnIndex(DownloadManager.COLUMN_BYTES_DOWNLOADED_SO_FAR) ?: 0
            )
        progress = ((downloaded?.times(100L) ?: 0L) / total).toInt()
        DbRepository.downloadContentClient.updateProgress(downloaded, mDownloadId)
        runOnUiThread{
            dialog?.mAdapter?.notifyDataSetChanged()
        }
        cursor.close()

        when (status) {
            DownloadManager.STATUS_FAILED -> {
              
            }
            DownloadManager.STATUS_PAUSED -> {
               
            }
            DownloadManager.STATUS_PENDING -> {
                
            }
            DownloadManager.STATUS_RUNNING -> {
              
            }
            DownloadManager.STATUS_SUCCESSFUL -> {
              
                progress = 100
                complete=false
            }
            else ->{
               
            }
        }
    }
}

}.start()

Try to get listnear of this cancel button

I tried from above code for getting notification cancel event which is system generated, but not getting any log from code.

0 Answers0