Fetch
Fetch copied to clipboard
Download File when app is killed or in background
HI i am unable to implement, download video when application is killed or in hide and no able to create notification can anyone provide me sample code for the same
any help would be appreciated Thanks
@vksBhardwaj Try using Android service. If you use Kotlin, Please tell me I will update the code Sample Code
Still any doubts, Please Ask
Thanks @Hacker437 for Quick reply. I ma using Kotlin it will be very helpful. if you update code in Kotlin
Thanks
Here is the gist in kotlin Gist
In your gist you have a BroadcastReceiver, not sure why you have one and you create a new instance of fetch in the onReceive method which also I am not sure what is supposed to be doing. There are now 2 different instances one in the service and one in the receiver, what is the point of this @Hacker437?
@DavidKmn Otherwise, I cannot pause, resume, cancel the download when the button is clicked. I don't know if it can be done in a single instance only @tonyofrancis can tell.
@tonyofrancis Any thoughts on this?
I think it is ok as long as they share same namespace
I have a question. Should I use my Fragment class (which has resume,start,cancel buttons of a download link) instead of DownloadService class ? Or I mean can I use the codes in the DownloadService in my fragment class directly ? At the end there is an url in the DownloadService but I get the url from the user which needs an edit text.
@passmanagerapp Yes you can use Fetch in a fragment.
@passmanagerapp Do you need background downloading?
@Hacker437 Yes I need background downloading
@Hacker437 But fragment can't extends Service. What should I do to start downloading process in Fragment and continue to backgrond downloading when app is killed or in background.
I have created a DownloadService class and DownloadCompleteReceiver as you did in the code. In fragmet, with a button I want to start the service, here is what I did for this:
button.setOnclickListener { serviceIntent = Intent(context(),DownloadService::class.java) serviceIntent.putExtra("requestID",request.id) context().startService(serviceIntent) }
btnPause.setOnclickListener { serviceIntent.putExtra("action","pause") }
How can I use the same fetch instance and request instance in Service in my Fragment ? Now the background process is working fine, but when I open the app, the UI is reset.
I am sorry I too don't know.
@vksBhardwaj Try using Android service. If you use Kotlin, Please tell me I will update the code Sample Code
Still any doubts, Please Ask
can you share your sample code. i could not find out your sample code
@Hacker437 can you provide me sample code, full working in background.