Android Question Android Download manager

Devv

Active Member
Licensed User
hi
i'am trying to download a file and open my app when the download notification is clicked

this is what i tried

B4X:
'Activity module
Sub Process_Globals

    Dim DOWNLOAD_ADDRESS As String="http://download.thinkbroadband.com/10MB.zip"
    Dim DOWNLOAD_FILENAME As String="wiki_logo.png"
   
    '    DownloadId is a unique identifier assigned by the DownloadManager to this download task
    Dim DownloadId As Long
   
End Sub

Sub Globals
   
    Dim DownloadButton As Button
    Dim DownloadManager1 As DownloadManager
   
    Dim ImageView1 As ImageView
End Sub

Sub Activity_Create(FirstTime As Boolean)
    Activity.LoadLayout("Main")
   
    '    RegisterReceiver enables DownloadManager to raise events
    DownloadManager1.RegisterReceiver("DownloadManager1")
   
End Sub

Sub Activity_Resume

End Sub

Sub Activity_Pause (UserClosed As Boolean)

End Sub

Sub DownloadButton_Click

    Dim DownloadManagerRequest1 As DownloadManagerRequest
    DownloadManagerRequest1.Initialize(DOWNLOAD_ADDRESS)
    DownloadManagerRequest1.Description="DownloadManager demo"
    '    save the download to external memory
    '    note you must manually update your project's manifest file adding android.permission.WRITE_EXTERNAL_STORAGE
    DownloadManagerRequest1.DestinationUri="file://"&File.Combine(File.DirRootExternal, DOWNLOAD_FILENAME)
    DownloadManagerRequest1.Title=DOWNLOAD_FILENAME
    DownloadManagerRequest1.VisibleInDownloadsUi=True
   
    DownloadId=DownloadManager1.Enqueue(DownloadManagerRequest1)
   
End Sub

Sub DownloadManager1_DownloadComplete(DownloadId1 As Long)
    '    this does not guarantee that the download has actually successfully downloaded
    '    it means a DownloadMananger DownloadManagerRequest has completed
    '    we need to find that status of that request but only if that request matches the request we started
   
    If DownloadId=DownloadId1 Then
        ToastMessageShow("finished downlaoding",False)
        DownloadManager1.UnregisterReceiver
    End If
   
End Sub

Sub DownloadManager1_NotificationClicked (DownloadIds() As Long)
    ToastMessageShow("you clicked notification",False)
End Sub

the download is working and i'am getting a toast when the download complete , but i never get any toast when i click the download notification , any ideas ?
 
Top