C# Class ExpansionDownloader.Service.DownloaderService

The downloader service.
Inheritance: ExpansionDownloader.Service.CustomIntentService, IDownloaderService
Afficher le fichier Open project: mattleibow/Android.Play.ExpansionLibrary Class Usage Examples

Méthodes publiques

Свойство Type Description
MaxRetryAfter int

Private Properties

Свойство Type Description
CancelAlarms void
GetNetworkAvailabilityState NetworkDisabledState
GetNetworkState NetworkState
HandleFileUpdated bool
PollNetworkState void
ScheduleAlarm void
UpdateLvl void
UpdateNetworkState void

Méthodes publiques

Méthode Description
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.

Méthodes protégées

Méthode Description
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.

Private Methods

Méthode Description
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.

Method Details

DownloaderService() protected méthode

Initializes a new instance of the DownloaderService class.
protected DownloaderService ( ) : System
Résultat System

GenerateSaveFile() public méthode

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. ///
Résultat string

GenerateTempSaveFileName() public méthode

Returns the filename (where the file should be saved) from info about a download
public GenerateTempSaveFileName ( string fileName ) : string
fileName string /// The file Name. ///
Résultat string

GetLogMessageForNetworkError() public méthode

a non-localized string appropriate for logging corresponding to one of the NETWORK_* constants.
public GetLogMessageForNetworkError ( NetworkDisabledState networkError ) : string
networkError NetworkDisabledState /// The network Error. ///
Résultat string

NotifyUpdateBytes() public méthode

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. ///
Résultat void

OnBind() public méthode

The on bind.
public OnBind ( Android.Content.Intent intent ) : IBinder
intent Android.Content.Intent /// The intent. ///
Résultat IBinder

OnClientUpdated() public méthode

The on client updated.
public OnClientUpdated ( Messenger messenger ) : void
messenger Messenger /// The client messenger. ///
Résultat void

OnCreate() public méthode

The on create.
public OnCreate ( ) : void
Résultat void

OnDestroy() public méthode

The on destroy.
public OnDestroy ( ) : void
Résultat void

OnHandleIntent() protected méthode

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. ///
Résultat void

RequestAbortDownload() public méthode

The request abort download.
public RequestAbortDownload ( ) : void
Résultat void

RequestContinueDownload() public méthode

The request continue download.
public RequestContinueDownload ( ) : void
Résultat void

RequestDownloadStatus() public méthode

The request download status.
public RequestDownloadStatus ( ) : void
Résultat void

RequestPauseDownload() public méthode

The request pause download.
public RequestPauseDownload ( ) : void
Résultat void

SetDownloadFlags() public méthode

The set download flags.
public SetDownloadFlags ( ServiceFlags flags ) : void
flags ServiceFlags /// The flags. ///
Résultat void

ShouldStop() protected méthode

Returns a value indicating whether the downloader should stop. This will return True if all the downloads are complete.
protected ShouldStop ( ) : bool
Résultat bool

StartDownloadServiceIfRequired() public static méthode

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. ///
Résultat DownloadServiceRequirement

StartDownloadServiceIfRequired() public static méthode

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. ///
Résultat DownloadServiceRequirement

Property Details

MaxRetryAfter public_oe static_oe property

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
Résultat int