C# Класс ExpansionDownloader.Service.DownloaderService

The downloader service.
Наследование: ExpansionDownloader.Service.CustomIntentService, IDownloaderService
Показать файл Открыть проект Примеры использования класса

Открытые свойства

Свойство Тип Описание
MaxRetryAfter int

Private Properties

Свойство Тип Описание
CancelAlarms void
GetNetworkAvailabilityState NetworkDisabledState
GetNetworkState NetworkState
HandleFileUpdated bool
PollNetworkState void
ScheduleAlarm void
UpdateLvl void
UpdateNetworkState void

Открытые методы

Метод Описание
GenerateSaveFile ( string filename, long filesize ) : string

Creates a filename (where the file should be saved) from info about a download.

GenerateTempSaveFileName ( string fileName ) : string

Returns the filename (where the file should be saved) from info about a download

GetLogMessageForNetworkError ( NetworkDisabledState networkError ) : string

a non-localized string appropriate for logging corresponding to one of the NETWORK_* constants.

NotifyUpdateBytes ( long totalBytesSoFar ) : void

Calculating a moving average for the speed so we don't get jumpy calculations for time etc.

OnBind ( Android.Content.Intent intent ) : IBinder

The on bind.

OnClientUpdated ( Messenger messenger ) : void

The on client updated.

OnCreate ( ) : void

The on create.

OnDestroy ( ) : void

The on destroy.

RequestAbortDownload ( ) : void

The request abort download.

RequestContinueDownload ( ) : void

The request continue download.

RequestDownloadStatus ( ) : void

The request download status.

RequestPauseDownload ( ) : void

The request pause download.

SetDownloadFlags ( ServiceFlags flags ) : void

The set download flags.

StartDownloadServiceIfRequired ( Android.Content.Context context, Android.Content.Intent intent, Type serviceType ) : DownloadServiceRequirement

This version assumes that the intent contains the pending intent as a parameter. This is used for responding to alarms. The pending intent must be in an extra with the key DownloaderService#PendingIntent.

StartDownloadServiceIfRequired ( Android.Content.Context context, Android.App.PendingIntent pendingIntent, Type serviceType ) : DownloadServiceRequirement

Starts the download if necessary.

This function starts a flow that does many things: 1) Checks to see if the APK version has been checked and the metadata database updated 2) If the APK version does not match, checks the new LVL status to see if a new download is required 3) If the APK version does match, then checks to see if the download(s) have been completed 4) If the downloads have been completed, returns DownloadServiceRequirement.NoDownloadRequired The idea is that this can be called during the startup of an application to quickly ascertain if the application needs to wait to hear about any updated APK expansion files. This does mean that the application MUST be run with a network connection for the first time, even if Market delivers all of the files.

Защищенные методы

Метод Описание
DownloaderService ( ) : System

Initializes a new instance of the DownloaderService class.

OnHandleIntent ( Android.Content.Intent intent ) : void

This is the main thread for the Downloader. This thread is responsible for queuing up downloads and other goodness.

ShouldStop ( ) : bool

Returns a value indicating whether the downloader should stop. This will return True if all the downloads are complete.

Приватные методы

Метод Описание
CancelAlarms ( ) : void

The cancel alarms.

GetNetworkAvailabilityState ( ) : NetworkDisabledState

The get network availability state.

GetNetworkState ( NetworkInfo info ) : NetworkState

Updates the network type based upon the info returned from the connectivity manager.

HandleFileUpdated ( string filename, long fileSize ) : bool

The APK has been updated and a filename has been sent down from the Market call. If the file has the same name as the previous file, we do nothing as the file is guaranteed to be the same. If the file does not have the same name, we download it if it hasn't already been delivered by Market.

PollNetworkState ( ) : void

Polls the network state, setting the flags appropriately.

ScheduleAlarm ( int wakeUp ) : void

The schedule alarm.

UpdateLvl ( DownloaderService context ) : void

Updates the LVL information from the server.

UpdateNetworkState ( NetworkInfo info ) : void

The update network state.

Описание методов

DownloaderService() защищенный Метод

Initializes a new instance of the DownloaderService class.
protected DownloaderService ( ) : System
Результат System

GenerateSaveFile() публичный Метод

Creates a filename (where the file should be saved) from info about a download.
public GenerateSaveFile ( string filename, long filesize ) : string
filename string /// The filename. ///
filesize long /// The filesize. ///
Результат string

GenerateTempSaveFileName() публичный Метод

Returns the filename (where the file should be saved) from info about a download
public GenerateTempSaveFileName ( string fileName ) : string
fileName string /// The file Name. ///
Результат string

GetLogMessageForNetworkError() публичный Метод

a non-localized string appropriate for logging corresponding to one of the NETWORK_* constants.
public GetLogMessageForNetworkError ( NetworkDisabledState networkError ) : string
networkError NetworkDisabledState /// The network Error. ///
Результат string

NotifyUpdateBytes() публичный Метод

Calculating a moving average for the speed so we don't get jumpy calculations for time etc.
public NotifyUpdateBytes ( long totalBytesSoFar ) : void
totalBytesSoFar long /// The total Bytes So Far. ///
Результат void

OnBind() публичный Метод

The on bind.
public OnBind ( Android.Content.Intent intent ) : IBinder
intent Android.Content.Intent /// The intent. ///
Результат IBinder

OnClientUpdated() публичный Метод

The on client updated.
public OnClientUpdated ( Messenger messenger ) : void
messenger Messenger /// The client messenger. ///
Результат void

OnCreate() публичный Метод

The on create.
public OnCreate ( ) : void
Результат void

OnDestroy() публичный Метод

The on destroy.
public OnDestroy ( ) : void
Результат void

OnHandleIntent() защищенный Метод

This is the main thread for the Downloader. This thread is responsible for queuing up downloads and other goodness.
protected OnHandleIntent ( Android.Content.Intent intent ) : void
intent Android.Content.Intent /// The intent that was recieved. ///
Результат void

RequestAbortDownload() публичный Метод

The request abort download.
public RequestAbortDownload ( ) : void
Результат void

RequestContinueDownload() публичный Метод

The request continue download.
public RequestContinueDownload ( ) : void
Результат void

RequestDownloadStatus() публичный Метод

The request download status.
public RequestDownloadStatus ( ) : void
Результат void

RequestPauseDownload() публичный Метод

The request pause download.
public RequestPauseDownload ( ) : void
Результат void

SetDownloadFlags() публичный Метод

The set download flags.
public SetDownloadFlags ( ServiceFlags flags ) : void
flags ServiceFlags /// The flags. ///
Результат void

ShouldStop() защищенный Метод

Returns a value indicating whether the downloader should stop. This will return True if all the downloads are complete.
protected ShouldStop ( ) : bool
Результат bool

StartDownloadServiceIfRequired() публичный статический Метод

This version assumes that the intent contains the pending intent as a parameter. This is used for responding to alarms. The pending intent must be in an extra with the key DownloaderService#PendingIntent.
public static StartDownloadServiceIfRequired ( Android.Content.Context context, Android.Content.Intent intent, Type serviceType ) : DownloadServiceRequirement
context Android.Content.Context /// Your application Context. ///
intent Android.Content.Intent /// An Intent to start the Activity in your application that /// shows the download progress and which will also start the /// application when downloadcompletes. ///
serviceType System.Type /// The type of the service to start. ///
Результат DownloadServiceRequirement

StartDownloadServiceIfRequired() публичный статический Метод

Starts the download if necessary.
This function starts a flow that does many things: 1) Checks to see if the APK version has been checked and the metadata database updated 2) If the APK version does not match, checks the new LVL status to see if a new download is required 3) If the APK version does match, then checks to see if the download(s) have been completed 4) If the downloads have been completed, returns DownloadServiceRequirement.NoDownloadRequired The idea is that this can be called during the startup of an application to quickly ascertain if the application needs to wait to hear about any updated APK expansion files. This does mean that the application MUST be run with a network connection for the first time, even if Market delivers all of the files.
public static StartDownloadServiceIfRequired ( Android.Content.Context context, Android.App.PendingIntent pendingIntent, Type serviceType ) : DownloadServiceRequirement
context Android.Content.Context /// Your application Context. ///
pendingIntent Android.App.PendingIntent /// A PendingIntent to start the Activity in your application that /// shows the download progress and which will also start the /// application when downloadcompletes. ///
serviceType System.Type /// The class of your implementation. ///
Результат DownloadServiceRequirement

Описание свойств

MaxRetryAfter публичное статическое свойство

The maximum amount of time that the download manager accepts for a Retry-After response header with a parameter in delta-seconds.
public static int MaxRetryAfter
Результат int