Sub Process_Globals
Dim mp3Url As String
mp3Url = "http://link_to_mp3"
End Sub
Sub Globals
End Sub
Sub Activity_Create(FirstTime As Boolean)
HttpUtils.CallbackActivity = "Main"
HttpUtils.CallbackJobDoneSub = "JobDone"
HttpUtils.Download("Job1", mp3Url)
End Sub
Sub Activity_Resume
If HttpUtils.Complete = True Then JobDone(HttpUtils.Job)
End Sub
Sub UrlDone(Url As String)
Log(Url & " done")
End Sub
Sub JobDone (Job As String)
Select Job
Case "Job1"
If HttpUtils.IsSuccess(mp3Url) Then
Dim mp3 As InputStream
mp3 = HttpUtils.GetInputStream(mp3Url)
File.Copy2(mp3,File.OpenOutput(File.DirRootExternal,"mySong.mp3",False))
End If
End Select
HttpUtils.Complete = False
End Sub
I've just had a go myself and I can't figure it out either. I do apologise :/
Edit: Scratch that. Pretty easy actually
B4X:Sub Process_Globals Dim mp3Url As String mp3Url = "http://link_to_mp3" End Sub Sub Globals End Sub Sub Activity_Create(FirstTime As Boolean) HttpUtils.CallbackActivity = "Main" HttpUtils.CallbackJobDoneSub = "JobDone" HttpUtils.Download("Job1", mp3Url) End Sub Sub Activity_Resume If HttpUtils.Complete = True Then JobDone(HttpUtils.Job) End Sub Sub UrlDone(Url As String) Log(Url & " done") End Sub Sub JobDone (Job As String) Select Job Case "Job1" If HttpUtils.IsSuccess(mp3Url) Then Dim mp3 As InputStream mp3 = HttpUtils.GetInputStream(mp3Url) File.Copy2(mp3,File.OpenOutput(File.DirRootExternal,"mySong.mp3",False)) End If End Select HttpUtils.Complete = False End Sub