|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectlu.thinds.android.RestService
public class RestService
This is an Android Service to provide REST functionality outside of the Application thread.
Field Summary | |
---|---|
static int |
GET
|
static int |
POST
|
Constructor Summary | |
---|---|
RestService(Handler mHandler,
Context mContext,
java.lang.String url)
Class constructor, requiring a handler (to receive a result), a context (to launch the service), and a url (to specify where to make the request). |
Method Summary | |
---|---|
void |
addHeader(java.lang.String name,
java.lang.String value)
Appends a header to the URL supplied by the constructor |
void |
addParam(java.lang.String name,
java.lang.String value)
Appends a parameter to the URL supplied by the constructor. |
void |
execute(int method)
Executes the current URL as a REST request in an IntentService. |
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final int GET
public static final int POST
Constructor Detail |
---|
public RestService(Handler mHandler, Context mContext, java.lang.String url)
In this implementation, name is written as a simple string and value as a UTF-8 Url Encoded Value.
mHandler
- The handler used to receive a response. Response is given to the msg object accessed in an Overridden handleMessage.mContext
- The context used to execute the service. Suggested to use getApplicationContext() to prevent leaks.url
- The url on which to execute the request.Method Detail |
---|
public void addParam(java.lang.String name, java.lang.String value)
In this implementation, name is written as a simple string and value as a UTF-8 Url Encoded Value.
name
- The name associated with the name/value pair for the url argumentvalue
- The value associated with the name/value pair for the url argumentpublic void addHeader(java.lang.String name, java.lang.String value)
name
- The name associated with the name/value pair for the url headervalue
- The value associated with the name/value pair for the url headerpublic void execute(int method)
The return string will be provided in the HandleMessage method of the handler provided by the constructor. It will be present as the object field of the incoming message.
method
- The type of HTTP request to make. Can be either RestService.GET or RestService.POST
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |