public abstract class DownloaderService extends CustomIntentService implements IDownloaderService
| Modifier and Type | Class and Description |
|---|---|
static class |
DownloaderService.GenerateSaveFileError
Exception thrown from methods called by generateSaveFile() for any fatal
error.
|
| Modifier and Type | Field and Description |
|---|---|
static String |
ACTION_DOWNLOAD_COMPLETE
Broadcast intent action sent by the download manager when a download
completes.
|
static String |
ACTION_DOWNLOAD_STATUS
Broadcast intent action sent by the download manager when download status
changes.
|
static String |
ACTION_DOWNLOADS_CHANGED |
static int |
CONTROL_PAUSED
This download must pause at the first opportunity.
|
static int |
CONTROL_RUN
This download is allowed to run.
|
static int |
DOWNLOAD_REQUIRED |
static String |
EXTRA_FILE_NAME |
static String |
EXTRA_IS_WIFI_REQUIRED
For intents used to notify the user that a download exceeds a size
threshold, if this extra is true, WiFi is required for this download
size; otherwise, it is only recommended.
|
static String |
EXTRA_MESSAGE_HANDLER |
static String |
EXTRA_PACKAGE_NAME |
static String |
EXTRA_PENDING_INTENT |
static String |
EXTRA_STATUS_CURRENT_FILE_SIZE |
static String |
EXTRA_STATUS_CURRENT_PROGRESS |
static String |
EXTRA_STATUS_STATE
Used with DOWNLOAD_STATUS
|
static String |
EXTRA_STATUS_TOTAL_PROGRESS |
static String |
EXTRA_STATUS_TOTAL_SIZE |
static int |
LVL_CHECK_REQUIRED |
static int |
NETWORK_CANNOT_USE_ROAMING
The current connection is roaming, and the download can't proceed over a
roaming connection.
|
static int |
NETWORK_MOBILE
Bit flag for
#setAllowedNetworkTypes corresponding to
ConnectivityManager.TYPE_MOBILE. |
static int |
NETWORK_NO_CONNECTION
There is no network connectivity.
|
static int |
NETWORK_OK
The network is usable for the given download.
|
static int |
NETWORK_RECOMMENDED_UNUSABLE_DUE_TO_SIZE
The download exceeds the recommended maximum size for this network, the
user must confirm for this download to proceed without WiFi.
|
static int |
NETWORK_TYPE_DISALLOWED_BY_REQUESTOR
The app requesting the download specific that it can't use the current
network connection.
|
static int |
NETWORK_UNUSABLE_DUE_TO_SIZE
The download exceeds the maximum size for this network.
|
static int |
NETWORK_WIFI
Bit flag for
#setAllowedNetworkTypes corresponding to
ConnectivityManager.TYPE_WIFI. |
static int |
NO_DOWNLOAD_REQUIRED |
static int |
STATUS_CANCELED
This download was canceled
|
static int |
STATUS_CANNOT_RESUME
Some possibly transient error occurred, but we can't resume the download.
|
static int |
STATUS_DEVICE_NOT_FOUND_ERROR
This download couldn't be completed because no external storage device
was found.
|
static int |
STATUS_FILE_ALREADY_EXISTS_ERROR
The requested destination file already exists.
|
static int |
STATUS_FILE_DELIVERED_INCORRECTLY
The file was delivered incorrectly
|
static int |
STATUS_FILE_ERROR
This download couldn't be completed because of a storage issue.
|
static int |
STATUS_FORBIDDEN
The requested URL is no longer available
|
static int |
STATUS_HTTP_DATA_ERROR
This download couldn't be completed because of an error receiving or
processing data at the HTTP level.
|
static int |
STATUS_HTTP_EXCEPTION
This download couldn't be completed because of an HttpException while
setting up the request.
|
static int |
STATUS_INSUFFICIENT_SPACE_ERROR
This download couldn't be completed due to insufficient storage space.
|
static int |
STATUS_PAUSED_BY_APP
This download has been paused by the owning app.
|
static int |
STATUS_PENDING
This download hasn't stated yet
|
static int |
STATUS_QUEUED_FOR_WIFI
This download is waiting for a Wi-Fi connection to proceed.
|
static int |
STATUS_QUEUED_FOR_WIFI_OR_CELLULAR_PERMISSION
This download is waiting for a Wi-Fi connection to proceed or for
permission to download over cellular.
|
static int |
STATUS_RUNNING
This download has started
|
static int |
STATUS_SUCCESS
This download has successfully completed.
|
static int |
STATUS_TOO_MANY_REDIRECTS
This download couldn't be completed because there were too many
redirects.
|
static int |
STATUS_UNHANDLED_HTTP_CODE
This download couldn't be completed because of an unspecified unhandled
HTTP code.
|
static int |
STATUS_UNHANDLED_REDIRECT
This download couldn't be completed because of an HTTP redirect response
that the download manager couldn't handle.
|
static int |
STATUS_UNKNOWN_ERROR
This download has completed with an error.
|
static int |
STATUS_WAITING_FOR_NETWORK
This download is waiting for network connectivity to proceed.
|
static int |
STATUS_WAITING_TO_RETRY
This download encountered some network error and is waiting before
retrying the request.
|
static int |
VISIBILITY_HIDDEN
This download doesn't show in the UI or in the notifications.
|
static int |
VISIBILITY_VISIBLE
This download is visible but only shows in the notifications while it's
in progress.
|
static int |
VISIBILITY_VISIBLE_NOTIFY_COMPLETED
This download is visible and shows in the notifications while in progress
and after completion.
|
START_CONTINUATION_MASK, START_FLAG_REDELIVERY, START_FLAG_RETRY, START_NOT_STICKY, START_REDELIVER_INTENT, START_STICKY, START_STICKY_COMPATIBILITYACCESSIBILITY_SERVICE, ACCOUNT_SERVICE, ACTIVITY_SERVICE, ALARM_SERVICE, AUDIO_SERVICE, BIND_ABOVE_CLIENT, BIND_ADJUST_WITH_ACTIVITY, BIND_ALLOW_OOM_MANAGEMENT, BIND_AUTO_CREATE, BIND_DEBUG_UNBIND, BIND_IMPORTANT, BIND_NOT_FOREGROUND, BIND_WAIVE_PRIORITY, CLIPBOARD_SERVICE, CONNECTIVITY_SERVICE, CONTEXT_IGNORE_SECURITY, CONTEXT_INCLUDE_CODE, CONTEXT_RESTRICTED, DEVICE_POLICY_SERVICE, DOWNLOAD_SERVICE, DROPBOX_SERVICE, INPUT_METHOD_SERVICE, INPUT_SERVICE, KEYGUARD_SERVICE, LAYOUT_INFLATER_SERVICE, LOCATION_SERVICE, MEDIA_ROUTER_SERVICE, MODE_APPEND, MODE_ENABLE_WRITE_AHEAD_LOGGING, MODE_MULTI_PROCESS, MODE_PRIVATE, MODE_WORLD_READABLE, MODE_WORLD_WRITEABLE, NFC_SERVICE, NOTIFICATION_SERVICE, NSD_SERVICE, POWER_SERVICE, SEARCH_SERVICE, SENSOR_SERVICE, STORAGE_SERVICE, TELEPHONY_SERVICE, TEXT_SERVICES_MANAGER_SERVICE, UI_MODE_SERVICE, USB_SERVICE, VIBRATOR_SERVICE, WALLPAPER_SERVICE, WIFI_P2P_SERVICE, WIFI_SERVICE, WINDOW_SERVICEFLAGS_DOWNLOAD_OVER_CELLULAR| Constructor and Description |
|---|
DownloaderService() |
| Modifier and Type | Method and Description |
|---|---|
String |
generateSaveFile(String filename,
long filesize)
Creates a filename (where the file should be saved) from info about a
download.
|
String |
generateTempSaveFileName(String fileName)
Returns the filename (where the file should be saved) from info about a
download
|
abstract String |
getAlarmReceiverClassName() |
int |
getControl() |
String |
getLogMessageForNetworkError(int networkError) |
int |
getNetworkAvailabilityState(DownloadsDB db) |
abstract String |
getPublicKey() |
abstract byte[] |
getSALT() |
int |
getStatus() |
boolean |
handleFileUpdated(DownloadsDB db,
int index,
String filename,
long fileSize)
The APK has been updated and a filename has been sent down from the
Market call.
|
static boolean |
isStatusClientError(int status)
Returns whether the status is a client error (i.e.
|
static boolean |
isStatusCompleted(int status)
Returns whether the download has completed (either with success or
error).
|
static boolean |
isStatusError(int status)
Returns whether the status is an error (i.e.
|
static boolean |
isStatusInformational(int status)
Returns whether the status is informational (i.e.
|
static boolean |
isStatusServerError(int status)
Returns whether the status is a server error (i.e.
|
static boolean |
isStatusSuccess(int status)
Returns whether the status is a success (i.e.
|
boolean |
isWiFi() |
void |
notifyUpdateBytes(long totalBytesSoFar) |
android.os.IBinder |
onBind(android.content.Intent paramIntent) |
void |
onClientUpdated(android.os.Messenger clientMessenger)
Call this when you get
IDownloaderClient.onServiceConnected(Messenger m) from the
DownloaderClient to register the client with the service. |
void |
onCreate() |
void |
onDestroy() |
protected void |
onHandleIntent(android.content.Intent intent)
This is the main thread for the Downloader.
|
void |
requestAbortDownload()
Request that the service abort the current download.
|
void |
requestContinueDownload()
Request that the service continue a paused download, when in any paused
or failed state, including
IDownloaderClient.STATE_PAUSED_BY_REQUEST. |
void |
requestDownloadStatus()
Requests that the download status be sent to the client.
|
void |
requestPauseDownload()
Request that the service pause the current download.
|
void |
setDownloadFlags(int flags)
Set the flags for this download (e.g.
|
protected boolean |
shouldStop() |
static int |
startDownloadServiceIfRequired(android.content.Context context,
android.content.Intent intent,
Class<?> serviceClass) |
static int |
startDownloadServiceIfRequired(android.content.Context context,
android.app.PendingIntent pendingIntent,
Class<?> serviceClass) |
static int |
startDownloadServiceIfRequired(android.content.Context context,
android.app.PendingIntent pendingIntent,
String classPackage,
String className)
Starts the download if necessary.
|
void |
updateLVL(android.content.Context context)
Updates the LVL information from the server.
|
onStart, onStartCommand, setIntentRedeliverydump, getApplication, onConfigurationChanged, onLowMemory, onRebind, onTaskRemoved, onTrimMemory, onUnbind, startForeground, stopForeground, stopSelf, stopSelf, stopSelfResultattachBaseContext, bindService, checkCallingOrSelfPermission, checkCallingOrSelfUriPermission, checkCallingPermission, checkCallingUriPermission, checkPermission, checkUriPermission, checkUriPermission, clearWallpaper, createPackageContext, databaseList, deleteDatabase, deleteFile, enforceCallingOrSelfPermission, enforceCallingOrSelfUriPermission, enforceCallingPermission, enforceCallingUriPermission, enforcePermission, enforceUriPermission, enforceUriPermission, fileList, getApplicationContext, getApplicationInfo, getAssets, getBaseContext, getCacheDir, getClassLoader, getContentResolver, getDatabasePath, getDir, getExternalCacheDir, getExternalFilesDir, getFilesDir, getFileStreamPath, getMainLooper, getObbDir, getPackageCodePath, getPackageManager, getPackageName, getPackageResourcePath, getResources, getSharedPreferences, getSystemService, getTheme, getWallpaper, getWallpaperDesiredMinimumHeight, getWallpaperDesiredMinimumWidth, grantUriPermission, isRestricted, openFileInput, openFileOutput, openOrCreateDatabase, openOrCreateDatabase, peekWallpaper, registerReceiver, registerReceiver, removeStickyBroadcast, revokeUriPermission, sendBroadcast, sendBroadcast, sendOrderedBroadcast, sendOrderedBroadcast, sendStickyBroadcast, sendStickyOrderedBroadcast, setTheme, setWallpaper, setWallpaper, startActivities, startActivities, startActivity, startActivity, startInstrumentation, startIntentSender, startIntentSender, startService, stopService, unbindService, unregisterReceiverpublic static final int NETWORK_OK
public static final int NETWORK_NO_CONNECTION
public static final int NETWORK_UNUSABLE_DUE_TO_SIZE
public static final int NETWORK_RECOMMENDED_UNUSABLE_DUE_TO_SIZE
public static final int NETWORK_CANNOT_USE_ROAMING
public static final int NETWORK_TYPE_DISALLOWED_BY_REQUESTOR
public static final String EXTRA_IS_WIFI_REQUIRED
public static final String EXTRA_FILE_NAME
public static final String EXTRA_STATUS_STATE
public static final String EXTRA_STATUS_TOTAL_SIZE
public static final String EXTRA_STATUS_CURRENT_FILE_SIZE
public static final String EXTRA_STATUS_TOTAL_PROGRESS
public static final String EXTRA_STATUS_CURRENT_PROGRESS
public static final String ACTION_DOWNLOADS_CHANGED
public static final String ACTION_DOWNLOAD_COMPLETE
public static final String ACTION_DOWNLOAD_STATUS
public static final int STATUS_PENDING
public static final int STATUS_RUNNING
public static final int STATUS_PAUSED_BY_APP
public static final int STATUS_WAITING_TO_RETRY
public static final int STATUS_WAITING_FOR_NETWORK
public static final int STATUS_QUEUED_FOR_WIFI_OR_CELLULAR_PERMISSION
public static final int STATUS_QUEUED_FOR_WIFI
public static final int STATUS_SUCCESS
public static final int STATUS_FORBIDDEN
public static final int STATUS_FILE_DELIVERED_INCORRECTLY
public static final int STATUS_FILE_ALREADY_EXISTS_ERROR
public static final int STATUS_CANNOT_RESUME
public static final int STATUS_CANCELED
public static final int STATUS_UNKNOWN_ERROR
public static final int STATUS_FILE_ERROR
STATUS_INSUFFICIENT_SPACE_ERROR and
STATUS_DEVICE_NOT_FOUND_ERROR when appropriate.public static final int STATUS_UNHANDLED_REDIRECT
public static final int STATUS_UNHANDLED_HTTP_CODE
public static final int STATUS_HTTP_DATA_ERROR
public static final int STATUS_HTTP_EXCEPTION
public static final int STATUS_TOO_MANY_REDIRECTS
public static final int STATUS_INSUFFICIENT_SPACE_ERROR
public static final int STATUS_DEVICE_NOT_FOUND_ERROR
public static final int CONTROL_RUN
public static final int CONTROL_PAUSED
public static final int VISIBILITY_VISIBLE
public static final int VISIBILITY_VISIBLE_NOTIFY_COMPLETED
public static final int VISIBILITY_HIDDEN
public static final int NETWORK_MOBILE
#setAllowedNetworkTypes corresponding to
ConnectivityManager.TYPE_MOBILE.public static final int NETWORK_WIFI
#setAllowedNetworkTypes corresponding to
ConnectivityManager.TYPE_WIFI.public static final int NO_DOWNLOAD_REQUIRED
public static final int LVL_CHECK_REQUIRED
public static final int DOWNLOAD_REQUIRED
public static final String EXTRA_PACKAGE_NAME
public static final String EXTRA_PENDING_INTENT
public static final String EXTRA_MESSAGE_HANDLER
public static boolean isStatusInformational(int status)
public static boolean isStatusSuccess(int status)
public static boolean isStatusError(int status)
public static boolean isStatusClientError(int status)
public static boolean isStatusServerError(int status)
public static boolean isStatusCompleted(int status)
public android.os.IBinder onBind(android.content.Intent paramIntent)
onBind in class CustomIntentServicepublic boolean isWiFi()
public static int startDownloadServiceIfRequired(android.content.Context context,
android.content.Intent intent,
Class<?> serviceClass)
throws android.content.pm.PackageManager.NameNotFoundException
android.content.pm.PackageManager.NameNotFoundExceptionpublic static int startDownloadServiceIfRequired(android.content.Context context,
android.app.PendingIntent pendingIntent,
Class<?> serviceClass)
throws android.content.pm.PackageManager.NameNotFoundException
android.content.pm.PackageManager.NameNotFoundExceptionpublic static int startDownloadServiceIfRequired(android.content.Context context,
android.app.PendingIntent pendingIntent,
String classPackage,
String className)
throws android.content.pm.PackageManager.NameNotFoundException
context - thisIntent - android.content.pm.PackageManager.NameNotFoundExceptionpublic void requestAbortDownload()
IDownloaderServiceIDownloaderClient.STATE_ABORTED.requestAbortDownload in interface IDownloaderServicepublic void requestPauseDownload()
IDownloaderServiceIDownloaderClient.STATE_PAUSED_BY_REQUEST.requestPauseDownload in interface IDownloaderServicepublic void setDownloadFlags(int flags)
IDownloaderServiceDownloaderService.FLAGS_DOWNLOAD_OVER_CELLULAR).setDownloadFlags in interface IDownloaderServicepublic void requestContinueDownload()
IDownloaderServiceIDownloaderClient.STATE_PAUSED_BY_REQUEST.requestContinueDownload in interface IDownloaderServicepublic abstract String getPublicKey()
public abstract byte[] getSALT()
public abstract String getAlarmReceiverClassName()
public void updateLVL(android.content.Context context)
context - public boolean handleFileUpdated(DownloadsDB db, int index, String filename, long fileSize)
index - the index of the file from market (0 = main, 1 = patch)filename - the name of the new filefileSize - the size of the new fileprotected void onHandleIntent(android.content.Intent intent)
onHandleIntent in class CustomIntentServicepublic void onDestroy()
onDestroy in class CustomIntentServicepublic int getNetworkAvailabilityState(DownloadsDB db)
public void onCreate()
onCreate in class CustomIntentServicepublic String generateTempSaveFileName(String fileName)
public String generateSaveFile(String filename, long filesize) throws DownloaderService.GenerateSaveFileError
public String getLogMessageForNetworkError(int networkError)
public int getControl()
public int getStatus()
public void notifyUpdateBytes(long totalBytesSoFar)
protected boolean shouldStop()
shouldStop in class CustomIntentServicepublic void requestDownloadStatus()
IDownloaderServicerequestDownloadStatus in interface IDownloaderServicepublic void onClientUpdated(android.os.Messenger clientMessenger)
IDownloaderServiceIDownloaderClient.onServiceConnected(Messenger m) from the
DownloaderClient to register the client with the service. It will
automatically send the current status to the client.onClientUpdated in interface IDownloaderServiceCopyright © 2012–2014 simpligility technologies inc.. All rights reserved.