package com.shsening.autouploadvideos.utils import android.app.DownloadManager import android.content.BroadcastReceiver import android.content.Context import android.content.Intent import android.content.IntentFilter import android.widget.Toast class DownloadReceiver(private val context: Context,private val downloadHelper: DownloadHelper) : BroadcastReceiver() { init { context.registerReceiver(this, IntentFilter(DownloadManager.ACTION_DOWNLOAD_COMPLETE)) } override fun onReceive(context: Context, intent: Intent) { val action = intent.action if (DownloadManager.ACTION_DOWNLOAD_COMPLETE == action) { val downloadId = intent.getLongExtra(DownloadManager.EXTRA_DOWNLOAD_ID, -1) if (downloadId != -1L) { // downoad finished } } } fun unregister() { context.unregisterReceiver(this) } }