public final class UploadService extends Service
| Modifier and Type | Field and Description |
|---|---|
static int |
BACKOFF_MULTIPLIER
Sets the backoff timer multiplier.
|
static int |
BUFFER_SIZE
Buffer size in bytes used for data transfer by the upload tasks.
|
static boolean |
EXECUTE_IN_FOREGROUND
If set to true, the service will go in foreground mode when doing uploads,
lowering the probability of being killed by the system on low memory.
|
static HttpStack |
HTTP_STACK
Sets the HTTP Stack to use to perform HTTP based upload requests.
|
static int |
IDLE_TIMEOUT
How many time to wait in idle (in milliseconds) before shutting down the service.
|
static int |
INITIAL_RETRY_WAIT_TIME
Sets the time to wait in milliseconds before the next attempt when an upload fails
for the first time.
|
static int |
KEEP_ALIVE_TIME_IN_SECONDS
When the number of threads is greater than UPLOAD_POOL_SIZE, this is the maximum time that
excess idle threads will wait for new tasks before terminating.
|
static int |
MAX_RETRY_WAIT_TIME
Sets the maximum time to wait in milliseconds between two upload attempts.
|
static String |
NAMESPACE
Sets the namespace used to broadcast events.
|
static int |
UPLOAD_POOL_SIZE
Sets how many threads to use to handle concurrent uploads.
|
START_CONTINUATION_MASK, START_FLAG_REDELIVERY, START_FLAG_RETRY, START_NOT_STICKY, START_REDELIVER_INTENT, START_STICKY, START_STICKY_COMPATIBILITY, STOP_FOREGROUND_DETACH, STOP_FOREGROUND_REMOVEACCESSIBILITY_SERVICE, ACCOUNT_SERVICE, ACTIVITY_SERVICE, ALARM_SERVICE, APP_OPS_SERVICE, APPWIDGET_SERVICE, AUDIO_SERVICE, BATTERY_SERVICE, BIND_ABOVE_CLIENT, BIND_ADJUST_WITH_ACTIVITY, BIND_ALLOW_OOM_MANAGEMENT, BIND_AUTO_CREATE, BIND_DEBUG_UNBIND, BIND_EXTERNAL_SERVICE, BIND_IMPORTANT, BIND_NOT_FOREGROUND, BIND_WAIVE_PRIORITY, BLUETOOTH_SERVICE, CAMERA_SERVICE, CAPTIONING_SERVICE, CARRIER_CONFIG_SERVICE, CLIPBOARD_SERVICE, COMPANION_DEVICE_SERVICE, CONNECTIVITY_SERVICE, CONSUMER_IR_SERVICE, CONTEXT_IGNORE_SECURITY, CONTEXT_INCLUDE_CODE, CONTEXT_RESTRICTED, DEVICE_POLICY_SERVICE, DISPLAY_SERVICE, DOWNLOAD_SERVICE, DROPBOX_SERVICE, FINGERPRINT_SERVICE, HARDWARE_PROPERTIES_SERVICE, INPUT_METHOD_SERVICE, INPUT_SERVICE, JOB_SCHEDULER_SERVICE, KEYGUARD_SERVICE, LAUNCHER_APPS_SERVICE, LAYOUT_INFLATER_SERVICE, LOCATION_SERVICE, MEDIA_PROJECTION_SERVICE, MEDIA_ROUTER_SERVICE, MEDIA_SESSION_SERVICE, MIDI_SERVICE, MODE_APPEND, MODE_ENABLE_WRITE_AHEAD_LOGGING, MODE_MULTI_PROCESS, MODE_NO_LOCALIZED_COLLATORS, MODE_PRIVATE, MODE_WORLD_READABLE, MODE_WORLD_WRITEABLE, NETWORK_STATS_SERVICE, NFC_SERVICE, NOTIFICATION_SERVICE, NSD_SERVICE, POWER_SERVICE, PRINT_SERVICE, RECEIVER_VISIBLE_TO_INSTANT_APPS, RESTRICTIONS_SERVICE, SEARCH_SERVICE, SENSOR_SERVICE, SHORTCUT_SERVICE, STORAGE_SERVICE, STORAGE_STATS_SERVICE, SYSTEM_HEALTH_SERVICE, TELECOM_SERVICE, TELEPHONY_SERVICE, TELEPHONY_SUBSCRIPTION_SERVICE, TEXT_CLASSIFICATION_SERVICE, TEXT_SERVICES_MANAGER_SERVICE, TV_INPUT_SERVICE, UI_MODE_SERVICE, USAGE_STATS_SERVICE, USB_SERVICE, USER_SERVICE, VIBRATOR_SERVICE, WALLPAPER_SERVICE, WIFI_AWARE_SERVICE, WIFI_P2P_SERVICE, WIFI_SERVICE, WINDOW_SERVICETRIM_MEMORY_BACKGROUND, TRIM_MEMORY_COMPLETE, TRIM_MEMORY_MODERATE, TRIM_MEMORY_RUNNING_CRITICAL, TRIM_MEMORY_RUNNING_LOW, TRIM_MEMORY_RUNNING_MODERATE, TRIM_MEMORY_UI_HIDDEN| Constructor and Description |
|---|
UploadService() |
| Modifier and Type | Method and Description |
|---|---|
static List<String> |
getTaskList()
Gets the list of the currently active upload tasks.
|
IBinder |
onBind(Intent intent) |
void |
onCreate() |
void |
onDestroy() |
int |
onStartCommand(Intent intent,
int flags,
int startId) |
static boolean |
stop(Context context)
Stops the service if no upload tasks are currently running
|
static boolean |
stop(Context context,
boolean forceStop)
Stops the service.
|
static void |
stopAllUploads()
Stop all the active uploads.
|
static void |
stopUpload(String uploadId)
Stops the upload task with the given uploadId.
|
getApplication, onConfigurationChanged, onLowMemory, onRebind, onStart, onTaskRemoved, onTrimMemory, onUnbind, startForeground, stopForeground, stopForeground, stopSelf, stopSelf, stopSelfResultbindService, checkCallingOrSelfPermission, checkCallingOrSelfUriPermission, checkCallingPermission, checkCallingUriPermission, checkPermission, checkSelfPermission, checkUriPermission, checkUriPermission, clearWallpaper, createConfigurationContext, createContextForSplit, createDeviceProtectedStorageContext, createDisplayContext, createPackageContext, databaseList, deleteDatabase, deleteFile, deleteSharedPreferences, enforceCallingOrSelfPermission, enforceCallingOrSelfUriPermission, enforceCallingPermission, enforceCallingUriPermission, enforcePermission, enforceUriPermission, enforceUriPermission, fileList, getApplicationContext, getApplicationInfo, getAssets, getBaseContext, getCacheDir, getClassLoader, getCodeCacheDir, getContentResolver, getDatabasePath, getDataDir, getDir, getExternalCacheDir, getExternalCacheDirs, getExternalFilesDir, getExternalFilesDirs, getExternalMediaDirs, getFilesDir, getFileStreamPath, getMainLooper, getNoBackupFilesDir, getObbDir, getObbDirs, getPackageCodePath, getPackageManager, getPackageName, getPackageResourcePath, getResources, getSharedPreferences, getSystemService, getSystemServiceName, getTheme, getWallpaper, getWallpaperDesiredMinimumHeight, getWallpaperDesiredMinimumWidth, grantUriPermission, isDeviceProtectedStorage, isRestricted, moveDatabaseFrom, moveSharedPreferencesFrom, openFileInput, openFileOutput, openOrCreateDatabase, openOrCreateDatabase, peekWallpaper, registerReceiver, registerReceiver, registerReceiver, registerReceiver, removeStickyBroadcast, removeStickyBroadcastAsUser, revokeUriPermission, revokeUriPermission, sendBroadcast, sendBroadcast, sendBroadcastAsUser, sendBroadcastAsUser, sendOrderedBroadcast, sendOrderedBroadcast, sendOrderedBroadcastAsUser, sendStickyBroadcast, sendStickyBroadcastAsUser, sendStickyOrderedBroadcast, sendStickyOrderedBroadcastAsUser, setTheme, setWallpaper, setWallpaper, startActivities, startActivities, startActivity, startActivity, startForegroundService, startInstrumentation, startIntentSender, startIntentSender, startService, stopService, unbindService, unregisterReceivergetColor, getColorStateList, getDrawable, getString, getString, getSystemService, getText, obtainStyledAttributes, obtainStyledAttributes, obtainStyledAttributes, obtainStyledAttributes, registerComponentCallbacks, unregisterComponentCallbackspublic static int UPLOAD_POOL_SIZE
public static int KEEP_ALIVE_TIME_IN_SECONDS
public static int IDLE_TIMEOUT
public static boolean EXECUTE_IN_FOREGROUND
public static String NAMESPACE
public static HttpStack HTTP_STACK
HurlStack implementation is used.public static int BUFFER_SIZE
public static int INITIAL_RETRY_WAIT_TIME
BACKOFF_MULTIPLIER to get the time to wait before the next attempt.public static int BACKOFF_MULTIPLIER
public static int MAX_RETRY_WAIT_TIME
BACKOFF_MULTIPLIER and it's not convenient that the value grows
indefinitely.public static void stopUpload(String uploadId)
uploadId - The unique upload idpublic static List<String> getTaskList()
public static void stopAllUploads()
public static boolean stop(Context context)
context - application contextpublic static boolean stop(Context context, boolean forceStop)
context - application contextforceStop - stops the service no matter if some tasks are runningpublic int onStartCommand(Intent intent, int flags, int startId)
onStartCommand in class Service