Stop file download in wp7 - windows-phone-7.1

Thanks in advance.
How can I stop downloading when some events occurred in wp7.For example when I am clicking a button named btnStop, all downloads should be terminated.

If a download is still in progess and you wish to cancel it simply call CancelAsync

Related

How to control upload extension initiated from controller center?

I implemented upload extension and setup RTMP server for broadcasting via upload extension. The broadcasting is initiated from control center, not through SetupUI extension. Since the SampleHandler.m doesn't provide RPBroadcastController, I can't programmatically pause or stop the broadcasting. I'd like to at least stop the broadcasting and show error message that the server is not available. I've looking through all WWDC docs, but couldn't find much info. Mobcrush is showing error message like "Not logged in", how they do that?
I found a mistakes in my code, finishBroadcastWithError function should call [super finishBroadcastWithError:] to call RPBroadcastController to stop broadcasting and show proper error message. You don't need to access RPBroadcastController nor need SetupUI to controller broadcast. That was it, I wasted 2 days on this, I wish no one do that.

iOS in background continue to upload the data

I create a timer,through open the GPS keep App alive every 3 mintues,and then upload data.Then I found the timer was suspended,but the app was alive.Please someone tell me?
You need to become acquainted with Background Execution, here are few useful links I've found so far:
https://developer.apple.com/library/content/documentation/iPhone/Conceptual/iPhoneOSProgrammingGuide/BackgroundExecution/BackgroundExecution.html
https://blog.newrelic.com/2016/01/13/ios9-background-execution/
https://www.raywenderlich.com/143128/background-modes-tutorial-getting-started

How to download file With Alamofire?

I want continue download After I press 'startDownload' button, (Use resumeData)
when I second time enter app after app terminated.
Here is my Example code:
https://github.com/wgywgy/AlamofireDownloadDemo/tree/master
where to find resumeData?
You should save the "cancelledData" in a file and in second time enter app after app terminated you can read the data from that file as NSData.

Resume download after app has been quit

I was wondering whether it was possible to resume a download after the app has been terminated by the user or the OS.
I can see that SKTDownloadManager has methods to pause and resume a download. However, these methods only work for current SKTDownloadObjectHelpers.
If I pull them out of SKTDownloadManager.storedDownloadObjects() after the app has been quit and then started again and throw them at SKTDownloadManager.sharedInstance().resumeDownloadForDownloadHelper() the manager won't resume the downloads.
I dug a little deeper into the code and that these downloads are not getting restarted is because of a lack of a proper status. SKTGroupedDownloadOperation.m:87:
if (self.currentRunningGroupedOperation.stateDownloadItem >= SKTMapDownloadItemStatusDownloading) {
return NO; //cannot start download,isntall, finsihed
}
So, my questions is whether it is even possible to resume downloads after the app has been terminated and if so how do I do it. Any help is appreciated :)
For resuming the download, you should trigger an event in the application:didFinishLaunching or after the application restarted:
[[SKDownloadManager sharedInstance] tryRestartDownloadsWithDelegate:self andDataSource:self];
Well you can use AFNetworking Classes for that. AFNetworkingDownloadclasses

Images download issue

I've got a problem while downloading images in my iOS app. My app has the ability to download images form my server, but when I close the app while the download is being done and then I reopen it, for the app the image was fully downloaded, but when I open it it's crashed (half of the image looks OK, but the other half is all grey) and I can't find the way to handle this case.
Is there a way to handle this case? I mean, is there a way to know if the image is crashed, or any other thing that let's me know that the image wasn't downloaded ok for me to redownload it?
Wrap the image download code in calls to UIApplication beginBackgroundTaskWithExpirationHandler: and UIApplication endBackgroundTask:. In the expiration handler, stop the download and delete the partial file.
This allows the download to keep going for a few minutes in the background giving it more of a chance to complete. If it doesn't complete you delete the partial file preventing the issue of having a bad image. Of course you need to try to download again when your app returns to the foreground.
I would suggest you download an image first to a temporary location and when operation is finished successfully you move the image to it's permanent location (and make changes to database).
First make sure image is fully downloaded and then save it on device. Do not stream directly on disk.

Resources