public class MobileServiceClient extends Object
Modifier and Type | Field and Description |
---|---|
static String |
GOOGLE_ACCOUNT_TYPE
Google account type
|
static String |
GOOGLE_USER_INFO_SCOPE
Authentication token type required for client login
|
static String |
UTF8_ENCODING
UTF-8 encoding
|
Constructor and Description |
---|
MobileServiceClient(MobileServiceClient client)
Constructor for the MobileServiceClient
|
MobileServiceClient(String appUrl,
String appKey,
Context context)
Constructor for the MobileServiceClient
|
MobileServiceClient(URL appUrl,
String appKey,
Context context)
Constructor for the MobileServiceClient
|
Modifier and Type | Method and Description |
---|---|
static com.google.gson.GsonBuilder |
createMobileServiceGsonBuilder()
Creates a GsonBuilder with custom serializers to use with Windows Azure
Mobile Services
|
AndroidHttpClientFactory |
getAndroidHttpClientFactory()
Gets the AndroidHttpClientFactory
|
String |
getAppKey()
Returns the Mobile Service application key
|
URL |
getAppUrl()
Returns The Mobile Service URL
|
Context |
getContext()
Gets the Context object used to create the MobileServiceClient
|
MobileServiceUser |
getCurrentUser()
Returns the current authenticated user
|
com.google.gson.GsonBuilder |
getGsonBuilder()
Gets the GsonBuilder used to in JSON Serialization/Deserialization
|
ServiceFilter |
getServiceFilter()
Gets the ServiceFilter.
|
<E> MobileServiceTable<E> |
getTable(Class<E> clazz)
Creates a MobileServiceTable
|
MobileServiceJsonTable |
getTable(String name)
Creates a MobileServiceJsonTable
|
<E> MobileServiceTable<E> |
getTable(String name,
Class<E> clazz)
Creates a MobileServiceTable
|
void |
invokeApi(String apiName,
ApiJsonOperationCallback callback)
Invokes a custom API using POST HTTP method
|
void |
invokeApi(String apiName,
byte[] content,
String httpMethod,
List< |
<E> void |
invokeApi(String apiName,
Class<E> clazz,
ApiOperationCallback<E> callback)
Invokes a custom API using POST HTTP method
|
void |
invokeApi(String apiName,
com.google.gson.JsonElement body,
ApiJsonOperationCallback callback)
Invokes a custom API using POST HTTP method
|
void |
invokeApi(String apiName,
com.google.gson.JsonElement body,
String httpMethod,
List<
Invokes a custom API
|
<E> void |
invokeApi(String apiName,
Object body,
Class<E> clazz,
ApiOperationCallback<E> callback)
Invokes a custom API using POST HTTP method
|
<E> void |
invokeApi(String apiName,
Object body,
String httpMethod,
List<
Invokes a custom API
|
void |
invokeApi(String apiName,
String httpMethod,
List<
Invokes a custom API
|
<E> void |
invokeApi(String apiName,
String httpMethod,
List<
Invokes a custom API
|
boolean |
isLoginInProgress()
Indicates if a login operation is in progress
|
void |
login(MobileServiceAuthenticationProvider provider,
com.google.gson.JsonObject oAuthToken,
UserAuthenticationCallback callback)
Invokes Windows Azure Mobile Service authentication using a
provider-specific oAuth token
|
void |
login(MobileServiceAuthenticationProvider provider,
String oAuthToken,
UserAuthenticationCallback callback)
Invokes Windows Azure Mobile Service authentication using a
provider-specific oAuth token
|
void |
login(MobileServiceAuthenticationProvider provider,
UserAuthenticationCallback callback)
Invokes an interactive authentication process using the specified
Authentication Provider
|
void |
login(String provider,
com.google.gson.JsonObject oAuthToken,
UserAuthenticationCallback callback)
Invokes Windows Azure Mobile Service authentication using a
provider-specific oAuth token
|
void |
login(String provider,
String oAuthToken,
UserAuthenticationCallback callback)
Invokes Windows Azure Mobile Service authentication using a
provider-specific oAuth token
|
void |
login(String provider,
UserAuthenticationCallback callback)
Invokes an interactive authentication process using the specified
Authentication Provider
|
void |
loginWithGoogleAccount(Activity activity,
Account account,
String scopes,
UserAuthenticationCallback callback)
Invokes Windows Azure Mobile Service authentication using a
the Google account registered in the device
|
void |
loginWithGoogleAccount(Activity activity,
Account account,
UserAuthenticationCallback callback)
Invokes Windows Azure Mobile Service authentication using a
the Google account registered in the device
|
void |
loginWithGoogleAccount(Activity activity,
String scopes,
UserAuthenticationCallback callback)
Invokes Windows Azure Mobile Service authentication using a
the Google account registered in the device
|
void |
loginWithGoogleAccount(Activity activity,
UserAuthenticationCallback callback)
Invokes Windows Azure Mobile Service authentication using a
the Google account registered in the device
|
void |
logout()
Log the user out of the Mobile Service
|
<T> void |
registerDeserializer(Type type,
com.google.gson.JsonDeserializer<T> deserializer)
Registers a JsonDeserializer for the specified type
|
<T> void |
registerSerializer(Type type,
com.google.gson.JsonSerializer<T> serializer)
Registers a JsonSerializer for the specified type
|
void |
setAndroidHttpClientFactory(AndroidHttpClientFactory mAndroidHttpClientFactory)
Sets the AndroidHttpClientFactory
|
void |
setContext(Context mContext)
Sets the Context object for the MobileServiceClient
|
void |
setCurrentUser(MobileServiceUser user)
Sets a user to authenticate the Mobile Service operations
|
void |
setGsonBuilder(com.google.gson.GsonBuilder gsonBuilder)
Sets the GsonBuilder used to in JSON Serialization/Deserialization
|
MobileServiceClient |
withFilter(ServiceFilter serviceFilter)
Adds a new filter to the MobileServiceClient
|
public static final String UTF8_ENCODING
public static final String GOOGLE_ACCOUNT_TYPE
public static final String GOOGLE_USER_INFO_SCOPE
public MobileServiceClient(String appUrl, String appKey, Context context) throws MalformedURLException
appUrl
- Mobile Service URLappKey
- Mobile Service application keycontext
- The Context where the MobileServiceClient is createdMalformedURLException
public MobileServiceClient(MobileServiceClient client)
client
- An existing MobileServiceClientpublic static com.google.gson.GsonBuilder createMobileServiceGsonBuilder()
public void login(MobileServiceAuthenticationProvider provider, UserAuthenticationCallback callback)
provider
- The provider used for the authentication processcallback
- Callback to invoke when the authentication process finishespublic void login(String provider, UserAuthenticationCallback callback)
provider
- The provider used for the authentication processcallback
- Callback to invoke when the authentication process finishespublic void login(MobileServiceAuthenticationProvider provider, com.google.gson.JsonObject oAuthToken, UserAuthenticationCallback callback)
provider
- The provider used for the authentication processoAuthToken
- A Json object representing the oAuth token used for
authenticationcallback
- Callback to invoke when the authentication process finishespublic void login(String provider, com.google.gson.JsonObject oAuthToken, UserAuthenticationCallback callback)
provider
- The provider used for the authentication processoAuthToken
- A Json object representing the oAuth token used for
authenticationcallback
- Callback to invoke when the authentication process finishespublic void login(MobileServiceAuthenticationProvider provider, String oAuthToken, UserAuthenticationCallback callback)
provider
- The provider used for the authentication processoAuthToken
- The oAuth token used for authenticationcallback
- Callback to invoke when the authentication process finishespublic void login(String provider, String oAuthToken, UserAuthenticationCallback callback)
provider
- The provider used for the authentication processoAuthToken
- The oAuth token used for authenticationcallback
- Callback to invoke when the authentication process finishespublic void loginWithGoogleAccount(Activity activity, UserAuthenticationCallback callback)
activity
- The activity that triggered the authenticationcallback
- Callback to invoke when the authentication process finishespublic void loginWithGoogleAccount(Activity activity, String scopes, UserAuthenticationCallback callback)
activity
- The activity that triggered the authenticationscopes
- The scopes used as authentication token type for logincallback
- Callback to invoke when the authentication process finishespublic void loginWithGoogleAccount(Activity activity, Account account, UserAuthenticationCallback callback)
activity
- The activity that triggered the authenticationaccount
- The account used for the login operationcallback
- Callback to invoke when the authentication process finishespublic void loginWithGoogleAccount(Activity activity, Account account, String scopes, UserAuthenticationCallback callback)
activity
- The activity that triggered the authenticationaccount
- The account used for the login operationscopes
- The scopes used as authentication token type for logincallback
- Callback to invoke when the authentication process finishespublic void logout()
public String getAppKey()
public URL getAppUrl()
public boolean isLoginInProgress()
public MobileServiceUser getCurrentUser()
public void setCurrentUser(MobileServiceUser user)
user
- The user used to authenticate requestspublic MobileServiceJsonTable getTable(String name)
name
- Table namepublic <E> MobileServiceTable<E> getTable(String name, Class<E> clazz)
name
- Table nameclazz
- The class used for data serializationpublic <E> MobileServiceTable<E> getTable(Class<E> clazz)
clazz
- The class used for table name and data serializationpublic <E> void invokeApi(String apiName, Class<E> clazz, ApiOperationCallback<E> callback)
apiName
- The API nameclazz
- The API result classcallback
- The callback to invoke after the API executionpublic <E> void invokeApi(String apiName, Object body, Class<E> clazz, ApiOperationCallback<E> callback)
apiName
- The API namebody
- The object to send as the request bodyclazz
- The API result classcallback
- The callback to invoke after the API executionpublic <E> void invokeApi(String apiName, String httpMethod, List<> parameters, Class<E> clazz, ApiOperationCallback<E> callback)
apiName
- The API namehttpMethod
- The HTTP Method used to invoke the APIparameters
- The query string parameters sent in the requestclazz
- The API result classcallback
- The callback to invoke after the API executionpublic <E> void invokeApi(String apiName, Object body, String httpMethod, List<> parameters, Class<E> clazz, ApiOperationCallback<E> callback)
apiName
- The API namebody
- The object to send as the request bodyhttpMethod
- The HTTP Method used to invoke the APIparameters
- The query string parameters sent in the requestclazz
- The API result classcallback
- The callback to invoke after the API executionpublic void invokeApi(String apiName, ApiJsonOperationCallback callback)
apiName
- The API namecallback
- The callback to invoke after the API executionpublic void invokeApi(String apiName, com.google.gson.JsonElement body, ApiJsonOperationCallback callback)
apiName
- The API namebody
- The json element to send as the request bodycallback
- The callback to invoke after the API executionpublic void invokeApi(String apiName, String httpMethod, List<> parameters, ApiJsonOperationCallback callback)
apiName
- The API namehttpMethod
- The HTTP Method used to invoke the APIparameters
- The query string parameters sent in the requestcallback
- The callback to invoke after the API executionpublic void invokeApi(String apiName, com.google.gson.JsonElement body, String httpMethod, List<> parameters, ApiJsonOperationCallback callback)
apiName
- The API namebody
- The json element to send as the request bodyhttpMethod
- The HTTP Method used to invoke the APIparameters
- The query string parameters sent in the requestcallback
- The callback to invoke after the API executionpublic void invokeApi(String apiName, byte[] content, String httpMethod, List<> requestHeaders, List< > parameters, ServiceFilterResponseCallback callback)
apiName
- The API namecontent
- The byte array to send as the request bodyhttpMethod
- The HTTP Method used to invoke the APIrequestHeaders
- The extra headers to send in the requestparameters
- The query string parameters sent in the requestcallback
- The callback to invoke after the API executionpublic MobileServiceClient withFilter(ServiceFilter serviceFilter)
serviceFilter
- public ServiceFilter getServiceFilter()
public com.google.gson.GsonBuilder getGsonBuilder()
public <T> void registerSerializer(Type type, com.google.gson.JsonSerializer<T> serializer)
type
- The type to use in the registrationserializer
- The serializer to use in the registrationpublic <T> void registerDeserializer(Type type, com.google.gson.JsonDeserializer<T> deserializer)
type
- The type to use in the registrationdeserializer
- The deserializer to use in the registrationpublic void setGsonBuilder(com.google.gson.GsonBuilder gsonBuilder)
mGsonBuilder
- The GsonBuilder to setpublic Context getContext()
public void setContext(Context mContext)
public AndroidHttpClientFactory getAndroidHttpClientFactory()
public void setAndroidHttpClientFactory(AndroidHttpClientFactory mAndroidHttpClientFactory)