public class UploadServiceBroadcastReceiver extends BroadcastReceiver implements UploadStatusDelegate
UploadService
events.
It provides the boilerplate code to properly handle broadcast messages coming from the
upload service and dispatch them to the proper handler method.BroadcastReceiver.PendingResult
Constructor and Description |
---|
UploadServiceBroadcastReceiver() |
Modifier and Type | Method and Description |
---|---|
void |
onCancelled(Context context,
UploadInfo uploadInfo)
Called when the upload is cancelled.
|
void |
onCompleted(Context context,
UploadInfo uploadInfo,
ServerResponse serverResponse)
Called when the upload is completed successfully.
|
void |
onError(Context context,
UploadInfo uploadInfo,
ServerResponse serverResponse,
Exception exception)
Called when an error happens during the upload.
|
void |
onProgress(Context context,
UploadInfo uploadInfo)
Called when the upload progress changes.
|
void |
onReceive(Context context,
Intent intent) |
void |
register(Context context)
Register this upload receiver.
If you use this receiver in an Activity , you have to call this method inside
Activity.onResume() , after super.onResume(); .If you use it in a Service , you have to
call this method inside Service.onCreate() , after super.onCreate(); . |
void |
unregister(Context context)
Unregister this upload receiver.
If you use this receiver in an Activity , you have to call this method inside
Activity.onPause() , after super.onPause(); .If you use it in a Service , you have to
call this method inside Service.onDestroy() . |
abortBroadcast, clearAbortBroadcast, getAbortBroadcast, getDebugUnregister, getResultCode, getResultData, getResultExtras, goAsync, isInitialStickyBroadcast, isOrderedBroadcast, peekService, setDebugUnregister, setOrderedHint, setResult, setResultCode, setResultData, setResultExtras
public void onReceive(Context context, Intent intent)
onReceive
in class BroadcastReceiver
public void register(Context context)
Activity
, you have to call this method inside
Activity.onResume()
, after super.onResume();
.Service
, you have to
call this method inside Service.onCreate()
, after super.onCreate();
.context
- context in which to register this receiverpublic void unregister(Context context)
Activity
, you have to call this method inside
Activity.onPause()
, after super.onPause();
.Service
, you have to
call this method inside Service.onDestroy()
.context
- context in which to unregister this receiverpublic void onProgress(Context context, UploadInfo uploadInfo)
UploadStatusDelegate
onProgress
in interface UploadStatusDelegate
context
- contextuploadInfo
- upload status informationpublic void onError(Context context, UploadInfo uploadInfo, ServerResponse serverResponse, Exception exception)
UploadStatusDelegate
onError
in interface UploadStatusDelegate
context
- contextuploadInfo
- upload status informationserverResponse
- response got from the server. It can be null if the server has not
responded or if the request has not reached the server due to a
networking problem.exception
- exception that caused the error. It can be null if the request successfully
reached the server, but it responded with a 4xx or 5xx status code.public void onCompleted(Context context, UploadInfo uploadInfo, ServerResponse serverResponse)
UploadStatusDelegate
onCompleted
in interface UploadStatusDelegate
context
- contextuploadInfo
- upload status informationserverResponse
- response got from the serverpublic void onCancelled(Context context, UploadInfo uploadInfo)
UploadStatusDelegate
onCancelled
in interface UploadStatusDelegate
context
- contextuploadInfo
- upload status information