androidrestpostandroid-async-httploopj

How to create context when sending json content?


Reading this question : POSTing JSON/XML using android-async-http (loopj) in order to post json where is the context value set ?

The accepted answer uses a context value as a parameter within post method invocation :

JSONObject jsonParams = new JSONObject();
jsonParams.put("notes", "Test api support");
StringEntity entity = new StringEntity(jsonParams.toString());
client.post(context, restApiUrl, entity, "application/json",
    responseHandler);

Where is the context set ? Previously I used RequestParams for sending data where context is not required but a context value is required when sending json data ?


Solution

  • Maybe this question should be deleted but can request the context from the main activity using : Context context = this.getApplicationContext();