Error with volley String Request POST Method
I think this is a missing import. Try long pressing on methods to check if you have a missing import
I’ve import all that i needed
Can you copy-paste the whole method in a comment? With the volly library you are using?
StringRequest strReq = new StringRequest(Request.Method.POST,
“http://trickbd.com/register/?=api”, new Response.Listener() {
@Override
public void onResponse(String response) {
Log.d(TAG, "Register Response: " + response.toString());
hideDialog();
try {
JSONObject jObj = new JSONObject(response);
int status = jObj.getInt("status");
if (status == 2){
// User successfully stored in WordPress
// Now, storing the user in sqlite
String user_id = jObj.getString("user_id");
JSONObject user = jObj.getJSONObject("user");
String name = user.getString("name");
String email = user.getString("email");
String created_at = user
.getString("created_at");
// Inserting row in users table
db.addUser(name, email, user_id, created_at);
Toast.makeText(getApplicationContext(), "User successfully registered. Try login now!", Toast.LENGTH_LONG).show();
// Launch login activity
Intent intent = new Intent(
RegisterActivity.this,
LoginActivity.class);
startActivity(intent);
finish();
}
else if (status == 1){
// Error occurred in registration. Get the error
// message
String errorMsg = "Error";
Toast.makeText(getApplicationContext(),
errorMsg, Toast.LENGTH_LONG).show();
}
else{
// Error occurred in registration. Get the error
// message
String errorMsg = "Error";
Toast.makeText(getApplicationContext(),
errorMsg, Toast.LENGTH_LONG).show();
}
} 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();
hideDialog();
}
}) {
@Override
protected Map<String, String> getParams() {
// Posting params to register url
Map<String, String> params = new HashMap<String, String>();
params.put("username", name);
params.put("email", email);
params.put("pass", password);
return params;
}
};
// Adding request to request queue
AppController.getInstance().addToRequestQueue(strReq, tag_string_req);
}
Same error here. Obviously the constructor is incorrect. I’m sorry I tried. Try searching the stackoverflow community for an answer or maybe wait for an answer here.
I’ve tried several answers from stack overflow but all in vain. Same error with the constructor.
Here’s a link to a situation similar to yours!
Hahaha Use Fast Android Networking Is Simple Man !
Just put those in variable.