@LevelUpApi(contract=INTERNAL) public abstract class AbstractNetworkRequestService extends IntentService
putExtras(android.content.Intent, com.scvngr.levelup.core.net.AbstractRequest, java.lang.String). Subclasses may override getRequest(Intent) to not require a request to be
passed in the start Intent.| Modifier and Type | Class and Description |
|---|---|
static class |
AbstractNetworkRequestService.BroadcastResult
Represents the result that has been broadcast from this service.
|
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, 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_IMPORTANT, BIND_NOT_FOREGROUND, BIND_WAIVE_PRIORITY, BLUETOOTH_SERVICE, CAMERA_SERVICE, CAPTIONING_SERVICE, CLIPBOARD_SERVICE, CONNECTIVITY_SERVICE, CONSUMER_IR_SERVICE, CONTEXT_IGNORE_SECURITY, CONTEXT_INCLUDE_CODE, CONTEXT_RESTRICTED, DEVICE_POLICY_SERVICE, DISPLAY_SERVICE, DOWNLOAD_SERVICE, DROPBOX_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, 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, PRINT_SERVICE, RESTRICTIONS_SERVICE, SEARCH_SERVICE, SENSOR_SERVICE, STORAGE_SERVICE, TELECOM_SERVICE, TELEPHONY_SERVICE, TELEPHONY_SUBSCRIPTION_SERVICE, TEXT_SERVICES_MANAGER_SERVICE, TV_INPUT_SERVICE, UI_MODE_SERVICE, USAGE_STATS_SERVICE, USB_SERVICE, USER_SERVICE, VIBRATOR_SERVICE, WALLPAPER_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 |
|---|
AbstractNetworkRequestService()
Constructs a new instance of the service.
|
| Modifier and Type | Method and Description |
|---|---|
static IntentFilter |
getIntentFilterForBroadcastResults() |
protected AbstractRequest |
getRequest(Intent intent)
Get the request to send with this service.
|
static AbstractNetworkRequestService.BroadcastResult |
getResultFromBroadcastIntent(Intent intent) |
protected static String |
getToken()
Gets a unique token that identifies a request.
|
protected abstract boolean |
handleResponse(Context context,
LevelUpResponse response)
Handle the response from the server.
|
static boolean |
isRequestFinishedBroadcastIntent(Intent intent) |
void |
onHandleIntent(Intent intent) |
static void |
putExtras(Intent intent,
AbstractRequest request,
String token) |
onBind, onCreate, onDestroy, onStart, onStartCommand, setIntentRedeliverydump, getApplication, onConfigurationChanged, onLowMemory, onRebind, onTaskRemoved, onTrimMemory, onUnbind, startForeground, stopForeground, stopSelf, stopSelf, stopSelfResultattachBaseContext, bindService, checkCallingOrSelfPermission, checkCallingOrSelfUriPermission, checkCallingPermission, checkCallingUriPermission, checkPermission, checkUriPermission, checkUriPermission, clearWallpaper, createConfigurationContext, createDisplayContext, createPackageContext, databaseList, deleteDatabase, deleteFile, enforceCallingOrSelfPermission, enforceCallingOrSelfUriPermission, enforceCallingPermission, enforceCallingUriPermission, enforcePermission, enforceUriPermission, enforceUriPermission, fileList, getApplicationContext, getApplicationInfo, getAssets, getBaseContext, getCacheDir, getClassLoader, getCodeCacheDir, getContentResolver, getDatabasePath, getDir, getExternalCacheDir, getExternalCacheDirs, getExternalFilesDir, getExternalFilesDirs, getExternalMediaDirs, getFilesDir, getFileStreamPath, getMainLooper, getNoBackupFilesDir, getObbDir, getObbDirs, getPackageCodePath, getPackageManager, getPackageName, getPackageResourcePath, getResources, getSharedPreferences, getSystemService, getTheme, getWallpaper, getWallpaperDesiredMinimumHeight, getWallpaperDesiredMinimumWidth, grantUriPermission, isRestricted, openFileInput, openFileOutput, openOrCreateDatabase, openOrCreateDatabase, peekWallpaper, registerReceiver, registerReceiver, removeStickyBroadcast, removeStickyBroadcastAsUser, revokeUriPermission, sendBroadcast, sendBroadcast, sendBroadcastAsUser, sendBroadcastAsUser, sendOrderedBroadcast, sendOrderedBroadcast, sendOrderedBroadcastAsUser, sendStickyBroadcast, sendStickyBroadcastAsUser, sendStickyOrderedBroadcast, sendStickyOrderedBroadcastAsUser, setTheme, setWallpaper, setWallpaper, startActivities, startActivities, startActivity, startActivity, startInstrumentation, startIntentSender, startIntentSender, startService, stopService, unbindService, unregisterReceivergetDrawable, getString, getString, getText, obtainStyledAttributes, obtainStyledAttributes, obtainStyledAttributes, obtainStyledAttributes, registerComponentCallbacks, unregisterComponentCallbackspublic AbstractNetworkRequestService()
public static void putExtras(Intent intent, AbstractRequest request, String token)
intent - The Intent to put the extras into.request - An AbstractRequest that the service will perform.token - A token uniquely identifying the original request to the service. Typically
obtained by calling getToken().public static IntentFilter getIntentFilterForBroadcastResults()
LocalBroadcastManager to receive
Intents when this service completes its work. The result of the request may be obtained by
calling getResultFromBroadcastIntent(android.content.Intent).public static boolean isRequestFinishedBroadcastIntent(Intent intent)
intent - The broadcast Intent that was received.public static AbstractNetworkRequestService.BroadcastResult getResultFromBroadcastIntent(Intent intent)
intent - The Intent received as a broadcast for the IntentFilter returned by getIntentFilterForBroadcastResults().protected abstract boolean handleResponse(Context context, LevelUpResponse response)
context - the Application context.response - the LevelUpResponse received from the server.public void onHandleIntent(Intent intent)
onHandleIntent in class IntentServiceprotected AbstractRequest getRequest(Intent intent)
putExtras(android.content.Intent, com.scvngr.levelup.core.net.AbstractRequest, java.lang.String). Subclasses can override this to build a request differently.intent - the intent used to start the service.AbstractRequest to send with the service.protected static String getToken()