Send post data to server using Volley android - android

I am trying to send some data to the server using the Volley library.
private void registerUser(final String email, final String username,
final String password) {
// Tag used to cancel the request
String tag_string_req = "req_register";
pDialog.setMessage("Registering ...");
StringRequest strReq = new StringRequest(Method.POST,
AppConfig.URL_REGISTER, new Response.Listener<String>() {
#Override
public void onResponse(String response) {
Log.d(TAG, "Register Response: " + response.toString());
try {
JSONObject jObj = new JSONObject(response);
// String status = jObj.getString("status");
// User successfully stored in MySQL
// Now store the user in sqlite
String name = jObj.getString("username");
String email = jObj.getString("email");
String password = jObj.getString("password");
// String created_at = user
//.getString("created_at");
// Inserting row in users table
// db.addUser(name, email);
// Launch login activity
Intent intent = new Intent(
RegisterActivity.this,
LoginActivity.class);
startActivity(intent);
finish();
} catch (JSONException e) {
e.printStackTrace();
}
}
}, new Response.ErrorListener() {
#Override
public void onErrorResponse(VolleyError error) {
Log.e(TAG, "Registration Error: " + error.getMessage());
Toast.makeText(getApplicationContext(),
error.getMessage(), Toast.LENGTH_LONG).show();
}
}) {
#Override
protected Map<String, String> getParams() {
// Posting params to register url
Map<String, String> params = new HashMap<String, String>();
params.put("email", email);
params.put("username", username);
params.put("password", password);
return params;
}
Unfortunately no json is sent and I get nothing back. Here is a sample of my logcat output. After sending a request successfully to the server, I want to get response with success/fail.
Register Response: ---- YOUR DATA ----
username=xxx&email=xxx%40gmail.com&password=xxxx&-------------------
05-05 14:56:55.002 2558-2558/app.victory.walking.thewalkingviktory
W/System.err﹕ org.json.JSONException: Value ---- of type java.lang.String
cannot be converted to JSONObject
05-05 14:56:55.002 2558-2558/app.victory.walking.thewalkingviktory
W/System.err﹕ at org.json.JSON.typeMismatch(JSON.java:111)
05-05 14:56:55.002 2558-2558/app.victory.walking.thewalkingviktory
W/System.err﹕ at org.json.JSONObject.<init>(JSONObject.java:160)
05-05 14:56:55.002 2558-2558/app.victory.walking.thewalkingviktory
W/System.err﹕ at org.json.JSONObject.<init>(JSONObject.java:173)
Any help please? Thanx.

private void postUsingVolley() {
String tag_json_obj = "json_obj_req";
final ProgressDialog pDialog = new ProgressDialog(this);
pDialog.setMessage("posting...");
pDialog.show();
final String mVendorId = DeviceDetails.getInstance(mContext).getVendor_id();
String mUserId = UserModel.getInstance(mContext).getUser_id();
final HashMap<String, String> postParams = new HashMap<String, String>();
sendFeedbackParams.put("key1", value1);
sendFeedbackParams.put("key2", value2);
sendFeedbackParams.put("key3", value3);
JsonObjectRequest jsonObjReq = new JsonObjectRequest(Request.Method.POST,
ApplicationData.POST_URL, new JSONObject(postParams),
new com.android.volley.Response.Listener<JSONObject>() {
#Override
public void onResponse(JSONObject response) {
//Log.d("TAG", response.toString());
try {
//Toast.makeText(mContext, response.getString("message"), Toast.LENGTH_LONG).show();
Toast.makeText(mContext, "Thank you for your post", Toast.LENGTH_LONG).show();
if (response.getBoolean("status")) {
pDialog.dismiss();
finish();
}
} catch (JSONException e) {
Log.e("TAG", e.toString());
}
pDialog.dismiss();
}
}, new com.android.volley.Response.ErrorListener() {
#Override
public void onErrorResponse(VolleyError error) {
//VolleyLog.d("TAG", "Error: " + error.getMessage());
pDialog.dismiss();
if (isNetworkProblem(error)) {
Toast.makeText(mContext, "Internet Problem", Toast.LENGTH_SHORT).show();
}
}
}) {
#Override
public String getBodyContentType() {
return "application/json; charset=utf-8";
}
#Override
public Map<String, String> getHeaders() throws AuthFailureError {
return getRequestHeaders();
}
};
jsonObjReq.setRetryPolicy(new DefaultRetryPolicy(8000, 0, DefaultRetryPolicy.DEFAULT_BACKOFF_MULT));
// Adding request to request queue
AppController.getInstance().addToRequestQueue(jsonObjReq, tag_json_obj);
}
Use Volley like this,... It is working for me.

First of all you are not sending json to your server. You are sending parametrized url with post method and getting json text as response.
I think the problem is the response from the server which is supposedly json. But from your log, this text "---- YOUR DATA ----" which you get from Log.d(TAG, "Register Response: " + response.toString()); is not at all json formatted . So you need to modify your server to respond in correct json format.

This is the solution. I had to use the JsonObjectRequest class and not the StringRequest on. What JsonRequest does is that it converts your HashMap key-value pairs into a JSON Format.
private void registerUser(String email_address,String username, String
password) {
String tag_json_obj = "json_obj_req";
final ProgressDialog pDialog = new ProgressDialog(this);
pDialog.setMessage("posting...");
pDialog.show();
final String mVendorId =
DeviceDetails.getInstance(mContext).getVendor_id();
String mUserId = UserModel.getInstance(mContext).getUser_id();
String location = getResources().getConfiguration().locale.getCountry();
final HashMap<String, String> postParams = new HashMap<String, String>
();
postParams.put("username", username);
postParams.put("email", email_address);
postParams.put("password", password);
postParams.put("location", location);
Response.Listener<JSONObject> listener;
Response.ErrorListener errorListener;
final JSONObject jsonObject = new JSONObject(postParams);
JsonObjectRequest jsonObjReq = new
JsonObjectRequest(AppConfig.URL_REGISTER, jsonObject,
new com.android.volley.Response.Listener<JSONObject>() {
#Override
public void onResponse(JSONObject response) {
//Log.d("TAG", response.toString());
try {
Toast.makeText(getApplicationContext(),
response.getString("message"), Toast.LENGTH_LONG).show();
// Toast.makeText(getApplicationContext(), "Thank
you for your post", Toast.LENGTH_LONG).show();
if (response.getString("status").equals("success")){
session.setLogin(true);
pDialog.dismiss();
Intent i = new
Intent(RegisterActivity.this,Welcome.class);
startActivity(i);
finish();
}
} catch (JSONException e) {
Log.e("TAG", e.toString());
}
pDialog.dismiss();
}
}, new com.android.volley.Response.ErrorListener() {
#Override
public void onErrorResponse(VolleyError error) {
//VolleyLog.d("TAG", "Error: " + error.getMessage());
pDialog.dismiss();
}
}) {
#Override
public String getBodyContentType() {
return "application/json; charset=utf-8";
}
};
// Adding request to request queue
AppController.getInstance().addToRequestQueue(jsonObjReq, tag_json_obj);
}

JSon post
public void makePostUsingVolley()
{
session = new SessionManager(getActivity().getApplicationContext());
session.checkLogin();
HashMap<String, String> user = session.getUserDetails();
final String token = user.get(SessionManager.KEY_NAME);
//Toast.makeText(getActivity().getApplicationContext(),name, Toast.LENGTH_SHORT).show();
final Map<String, String> params = new HashMap<String, String>();
//params.put("Employees",name);
String tag_json_obj = "json_obj_req";
String url = "enter your url";
final ProgressDialog pDialog = new ProgressDialog(getApplicationContext());
pDialog.setMessage("Loading...");
pDialog.show();
StringRequest req = new StringRequest(Request.Method.GET,url,
new Response.Listener<String>() {
// final JsonObjectRequest jsonObjReq = new JsonObjectRequest(Request.Method.GET,
//"http://emservices.azurewebsites.net/Employee.asmx/CheckUserGet", new Response.Listener<JSONObject>() {
#Override
public void onResponse(String response) {
JSONObject json;
// Toast.makeText(getActivity().getApplicationContext(),"dfgghfhfgjhgjghjuhj", Toast.LENGTH_SHORT).show();
//Toast.makeText(getActivity().getApplicationContext(),obb.length(), Toast.LENGTH_SHORT).show();
// JSONObject data=obj.getJSONObject("Employee_Name");
ObjectOutput out = null;
try {
json = new JSONObject(response);
} catch (IOException e) {
e.printStackTrace();
} catch (JSONException e) {
e.printStackTrace();
}
pDialog.hide();
// Toast.makeText(getApplicationContext(),"hi", Toast.LENGTH_SHORT).show();
Log.d("", response);
}
}, new Response.ErrorListener() {
#Override
public void onErrorResponse(VolleyError error) {
VolleyLog.d("", "Error: " + error.getMessage());
Toast.makeText(getActivity().getApplicationContext(),
error.getMessage(), Toast.LENGTH_SHORT).show();
pDialog.hide();
// hide the progress dialog
}
}) {
#Override
protected Map<String, String> getParams() {
Map<String, String> params = new HashMap<String, String>();
params.put("username",name);
params.put("password",password);
return params;
}
};
// Adding request to request queue
AppController.getInstance().addToRequestQueue(req, tag_json_obj);
}

requestQueue= Volley.newRequestQueue(MainActivity.this);
StringRequest request=new StringRequest(Request.Method.PUT, url, new Response.Listener<String>() {
#Override
public void onResponse(String response) {
Toast.makeText(MainActivity.this, ""+response, Toast.LENGTH_SHORT).show();
Log.d("response",response);
}
}, new Response.ErrorListener() {
#Override
public void onErrorResponse(VolleyError error) {
}
}){
#Override
protected Map<String, String> getParams() throws AuthFailureError {
JSONObject jsonObject = new JSONObject();
try {
jsonObject.put("name", name.getText().toString().trim());
jsonObject.put("email", email.getText().toString().trim());
jsonObject.put("phone", phone.getText().toString().trim());
} catch (JSONException e) {
e.printStackTrace();
}
Map<String, String> params = new HashMap<String, String>();
params.put("message", jsonObject.toString());
return params;
}
};
requestQueue.add(request);
[["deep","dee#gmail.com","8888999999"]]

Related

How to solve Error in json parsing using volley POST?

Hi I am using volley as JSON Parsing. I am using POST method and sending parameters in post request. I am getting following error when parsing the data, I am getting following error. I want to use volley. I have tried with JsonArrayRequest but it does not allow to send parameters as JSONObject,which I am using in my code.
org.json.JSONArray cannot be converted to JSONObject
Request is like
{
"city":"acd",
"user_id":"82",
"phone_number1":"1232131231",
"my_type":"asf"
}
Response is like
[{
"name":"dfdfd",
}]
Following is my code
private void Search_Refer() {
//initialize the progress dialog and show it
progressDialog = new ProgressDialog(SearchReferNameActivity.this);
progressDialog.setMessage("Please wait....");
progressDialog.show();
try {
JSONObject jsonBody = new JSONObject();
jsonBody.put("city", "acb");
jsonBody.put("user_id", "82");
jsonBody.put("phone_number1", "12332123231");
jsonBody.put("my_type", "asf");
JsonObjectRequest jsonOblect = new JsonObjectRequest(Request.Method.POST, Constants.BASE_URL1+"api/lab/search", jsonBody, new Response.Listener<JSONObject>() {
#Override
public void onResponse(JSONObject response) {
Toast.makeText(getApplicationContext(), response.toString(), Toast.LENGTH_LONG).show();
Log.e("Search EROOR", response.toString());
try {
JSONArray itemArray=new JSONArray(response);
dataModelArrayList = new ArrayList<>();
for (int i = 0; i < itemArray.length(); i++) {
SearchModel playerModel = new SearchModel();
JSONObject dataobj = itemArray.getJSONObject(i);
//playerModel.setProduct_name(dataobj.getString("name"));
playerModel.setRadiology_store_first_name(dataobj.getString("radiology_store_first_name"));
dataModelArrayList.add(playerModel);
}
} catch (JSONException e) {
e.printStackTrace();
}
progressDialog.dismiss();
/* Intent intent = new Intent(SearchReferNameActivity.this, SearchResult.class);
intent.putExtra("Search_result", dataModelArrayList);
startActivity(intent);*/
}
}, new Response.ErrorListener() {
#Override
public void onErrorResponse(VolleyError error) {
Toast.makeText(getApplicationContext(), "Response: " + error.toString(), Toast.LENGTH_SHORT).show();
System.out.println("Search Eroor"+error.toString());
progressDialog.dismiss();
}
}){
#Override
public String getBodyContentType() {
return "application/json";
}
#Override
public Map<String, String> getHeaders() throws AuthFailureError {
HashMap<String, String> headers = new HashMap<String, String>();
headers.put("Authorization", "Bearer "+deviceToken);
return headers;
}
};
jsonOblect.setRetryPolicy(new DefaultRetryPolicy(
10000,
DefaultRetryPolicy.DEFAULT_MAX_RETRIES,
DefaultRetryPolicy.DEFAULT_BACKOFF_MULT));
MyApplication.getInstance().addToRequestQueue(jsonOblect,"postrequest");
} catch (JSONException e) {
e.printStackTrace();
}
// Toast.makeText(getApplicationContext(), "done", Toast.LENGTH_LONG).show();
}
Use JsonArrayRequest or StringRequest in place of JsonObjectRequest
JsonArrayRequest
change the following response parameter to JSONArray
Instead of new Response.Listener<JSONObject> Use new Response.Listener<JSONArray>
// JSONArray insated of JSONObject
public void onResponse(JSONArray response) {
}
Use Below code
StringRequest stringRequest = new StringRequest(Request.Method.POST, "api/lab/search", new Response.Listener<String>() {
#Override
public void onResponse(String response) {
}
}, new Response.ErrorListener() {
#Override
public void onErrorResponse(VolleyError error) {
}
}) {
#Override
protected Map<String, String> getParams() throws AuthFailureError {
Map<String, String> params = new HashMap<>();
params.put("city", "abcd");
params.put("user_id", "82");
params.put("phone_number1", "01235467895");
params.put("my_type", "asf");
return params;
}
};

How to make android Volley request with body like following

I have following request in postman and I want to implement it in volley, android.
Any solution?
following is request header
Following is request body
Do like this .Add headers data like this.
RequestQueue queue = Volley.newRequestQueue(this);
String url = APICLient.BASE_URL+"api/Admin_controller/getProspectField";
StringRequest stringRequest = new StringRequest(Request.Method.POST, url,
new Response.Listener<String>() {
#Override
public void onResponse(String response) {
try {
JSONObject jo=new JSONObject(response);
Boolean status=jo.getBoolean("success");
JSONArray ja=jo.getJSONArray("user");
// write your logic here...
for (int i=0;i<ja.length();i++){
JSONObject jsonObject=ja.getJSONObject(i);
String pname=jsonObject.getString("p_name");
String pType=jsonObject.getString("p_type");
}
} catch (JSONException e) {
e.printStackTrace();
}
}
}, new Response.ErrorListener() {
#Override
public void onErrorResponse(VolleyError error) {
error.printStackTrace();
}
}) {
#Override
public Map<String, String> getHeaders(){
HashMap <String,String> params=new HashMap<>();
params.put("authorization","put_authorization_key_here");
return params;
}
#Override
public Map<String, String> getParams(){
HashMap <String,String> params=new HashMap<>();
params.put("care_team[]",team);
........................
return params;
}
};
queue.add(stringRequest);
Hope this will work.
Json Parsing with volley:
private void userLogin() {
StringRequest stringRequest = new StringRequest(Request.Method.POST, URLs.URL_LOGIN,
new Response.Listener<String>() {
#Override
public void onResponse(String response) {
try {
//converting response to json object
JSONObject obj = new JSONObject(response);
//if no error in response
if (obj.getBoolean("status")) {
Toast.makeText(getApplicationContext(), obj.getString("message"), Toast.LENGTH_SHORT).show();
//getting the user from the response
JSONObject userJson = obj.getJSONObject("user");
//creating a new user object
User user = new User(
userJson.getInt("cid"),
userJson.getInt("company_id"),
userJson.getString("name"),
userJson.getString("email")
);
//storing the user in shared preferences
SharedPreferenceManager.getInstance(getApplicationContext()).userLogin(user);
//starting the profile activity
finish();
startActivity(new Intent(getApplicationContext(), MainActivity.class));
} else {
Toast.makeText(getApplicationContext(), obj.getString("message"), Toast.LENGTH_SHORT).show();
progressBar.setVisibility(View.GONE);
}
} catch (JSONException e) {
e.printStackTrace();
progressBar.setVisibility(View.GONE);
}
}
},
new Response.ErrorListener() {
#Override
public void onErrorResponse(VolleyError error) {
Toast.makeText(getApplicationContext(), error.getMessage(), Toast.LENGTH_SHORT).show();
progressBar.setVisibility(View.GONE);
}
})
{
#Override
protected Map<String, String> getParams() throws AuthFailureError {
Map<String, String> params = new HashMap<>();
params.put("company_id",companyid );
params.put("email", username);
params.put("password", password);
return params;
}
#Override
public Map<String, String> getHeaders() throws AuthFailureError {
HashMap<String, String> headers = new HashMap<String, String>();
headers.put("x-api-key", "swicons#1019");
return headers;
}
};
stringRequest.setShouldCache(false);
VolleySingleton.getInstance(this).addToRequestQueue(stringRequest);
}

My response in Volley request always get into Error Listener

i am using volly for json response this is my java code i tried every thing but unable to find error in it. it always go to Error Listener.i really dont know why my response goes to error listener any body help me please thanks in advance
private void userLoign() {
name = Name_Et.getText().toString();
email = Email_Et.getText().toString();
password = Password_Et.getText().toString();
Toast.makeText(MainActivity.this, "enter in userlogin", Toast.LENGTH_SHORT).show();
RequestQueue queue = Volley.newRequestQueue(getApplicationContext());
String URL = "added-platters.000webhostapp.com/application/index.php";
Toast.makeText(MainActivity.this, "enter in Volley", Toast.LENGTH_SHORT).show();
StringRequest myReq = new StringRequest(Request.Method.POST, URL, new Response.Listener<String>() {
#Override
public void onResponse(String response) {
try {
JSONObject jObj = new JSONObject(response);
int success = jObj.getInt("value");
Log.e("value in success", String.valueOf(success));
Toast.makeText(MainActivity.this, "success", Toast.LENGTH_SHORT).show();
} catch (JSONException e) {
Log.i("myTag", e.toString());
Toast.makeText(MainActivity.this, "Parsing error", Toast.LENGTH_SHORT).show();
}
}
},
new Response.ErrorListener() {
#Override
public void onErrorResponse(VolleyError error) {
Log.i("myTag", error.toString());
Toast.makeText(MainActivity.this, "Server Error", Toast.LENGTH_SHORT).show();
}
}) {
#Override
protected Map<String, String> getParams() {
// Posting params to register url
Map<String, String> params = new HashMap<String, String>();
params.put("tag", "Register");
params.put("name", name);
params.put("email", email);
params.put("password", password);
params.put("lat", "1234");
params.put("log", "1234");
return params;
}
};
myReq.setRetryPolicy(new DefaultRetryPolicy(
20000, DefaultRetryPolicy.DEFAULT_MAX_RETRIES, DefaultRetryPolicy.DEFAULT_BACKOFF_MULT
));
myReq.setShouldCache(false);
queue.add(myReq);
}
and this is my json response in php
{"value":"Record Inserted Successfully"}
The Problem is URL Protocol not specified
String URL = "added-platters.000webhostapp.com/application/index.php";
to
String URL = "http://added-platters.000webhostapp.com/application/index.php";

Android Volley String Request Null Value in Params

While String request the post params value getting null and shows the error
NetworkDispatcher.run: Unhandled exception java.lang.NullPointerException: Attempt to invoke virtual method 'int java.lang.String.length()' on a null object reference
I have done debugging and one of the values is coming as null.
Here is my code,
public void getResponsePOST(Activity activity, final String[] name,
final String[] value) {
final CustomProgressBar pDialog = new CustomProgressBar(activity,R.drawable.loading);
//pDialog.setMessage("Loading...");
pDialog.show();
String tag_json_obj = "string_req";
System.out.println("URL PRODUCT"+mRequestUrl);
// RequestQueue queue = Volley.newRequestQueue(activity);
StringRequest sr = new StringRequest(Request.Method.POST, mRequestUrl,
new Response.Listener<String>() {
#Override
public void onResponse(String response) {
// Log.v("LOG", "9122014 " + response);
mResponseListener.responseSuccess(response.toString());
pDialog.dismiss();
}
}, new Response.ErrorListener() {
#Override
public void onErrorResponse(VolleyError error) {
// Log.v("LOG", "9122014 " + error);
VolleyLog.d(TAG, "Error: " + error.getMessage());
mResponseListener.responseFailure(error.getMessage());
pDialog.dismiss();
}
}) {
#Override
protected Map<String, String> getParams() {
Map<String, String> params = new HashMap<String, String>();
for (int i = 0; i < name.length; i++) {
try
{
params.put(name[i], value[i]);
}
catch(Exception e)
{
}
//System.out.println("Names:"+name[i]);
//System.out.println("Values:"+value[i]);
}
return params;
}
#Override
public Map<String, String> getHeaders() throws AuthFailureError {
Map<String, String> params = new HashMap<String, String>();
params.put("Content-Type", "application/x-www-form-urlencoded");
return params;
}
};
//Setting Timout Parameter : Bibin
sr.setRetryPolicy(new DefaultRetryPolicy(1800 * 1000,DefaultRetryPolicy.DEFAULT_MAX_RETRIES , DefaultRetryPolicy.DEFAULT_BACKOFF_MULT));
// Adding request to request queue
AppController.getInstance().addToRequestQueue(sr, tag_json_obj);
}
How to solve this issue?
You have to try this one :-
try {
StringRequest stringRequest = new StringRequest(Request.Method.POST, URL,
new Response.Listener<String>() {
#Override
public void onResponse(String response) {
progressDialog.dismiss();
System.out.println("Response is : " + response);
try {
JSONObject jsonLogin = new JSONObject(response);
if (jsonLogin.getInt("status") == 1) {
} else {
Toast.makeText(getActivity(), jsonLogin.getString("MSG"), Toast.LENGTH_LONG).show();
}
} catch (Exception ex) {
System.out.println("EXCEPTION IN SUCCESS OF LOGIN REQUEST : " + ex.toString());
}
}
},
new Response.ErrorListener() {
#Override
public void onErrorResponse(VolleyError error) {
progressDialog.dismiss();
System.out.println("ERROR IN LOGIN STRING REQUEST : " + error.getMessage());
}
}) {
#Override
protected Map<String, String> getParams() {
Map<String, String> params = new HashMap<String, String>();
params.put("USERID", "US-485212391");
return params;
}
};
RequestQueue requestQueue = Volley.newRequestQueue(getActivity());
requestQueue.add(stringRequest);
progressDialog = new ProgressDialog(getActivity());
progressDialog.setMessage("LoggingIn...");
progressDialog.show();
} catch (Exception ex) {
System.out.println(" Exception : " + ex);
}

Send login data to server using AndroidStudio

I am trying to send some data(login data - phonenumber, password) to the server using the Volley library.
The tool is AndroidStudio.
private void checkLogin(final String phonenumber, final String password){
String tag_string_req = "req_login";
pDialog.setMessage("Logging in...");
showDialog();
StringRequest strReq = new StringRequest(Method.POST, AppConfig.URL_REGISTER, new Response.Listener<String>(){
#Override
public synchronized void onResponse(String response){
Log.d(TAG, "login_response: " + response.toString());
hideDialog();
try{
JSONObject jObj = new JSONObject(response);
boolean error = jObj.getBoolean("error");
//check for error node in json
if(!error){
//user successfully logged in
//create login session
session.setLogin(true);
//launch main activity
Intent intent = new Intent(LoginActivity.this, MainActivity.class);
startActivity(intent);
finish();
}
else{
//error in login. get the error message
String errorMsg = jObj.getString("error_msg");
Toast.makeText(getApplicationContext(), errorMsg, Toast.LENGTH_LONG).show();
}
}catch (JSONException e){
//JSON error
e.printStackTrace();
}
}
}, new Response.ErrorListener(){
#Override
public synchronized void onErrorResponse(VolleyError error){
Log.e(TAG, "login_error: "+error.getMessage());
Toast.makeText(getApplicationContext(), error.getMessage(), Toast.LENGTH_LONG).show();
hideDialog();
}
}) {
#Override
protected Map<String, String> getParams(){
//posting parameters to login url
Map<String, String> params = new HashMap<String, String>();
params.put("tag", "login");
params.put("phonenumber", phonenumber);
params.put("password", password);
return params;
}
};
//adding request to request queue
AppController.getInstance().addToRequestQueue(strReq, tag_string_req);
}
private void showDialog(){
if(!pDialog.isShowing())
pDialog.show();
}
private void hideDialog(){
if(pDialog.isShowing())
pDialog.dismiss();
}
}
Unfortunately no json is sent to server.
Here is the code. Please help me.
To send Json with request you have to use 'JsonObjectRequest':
JsonObjectRequest registrationRequest = new JsonObjectRequest('Your URL', "your json object",
new Response.Listener<JSONObject>() {
#Override
public void onResponse(JSONObject response) {
Log.d(TAG, response.toString());
}, new Response.ErrorListener() {
#Override
public void onErrorResponse(VolleyError error) {
Log.d(TAG, error.getMessage());
}
});
AppController.getInstance().addToRequestQueue(registrationRequest);
Hope It will help.!!

Categories

Resources