I have an obstacle by changing the data string into a jsonobject, is his org.json.JSONException script error: Value
This coding I am trying
btnLogin.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
String username = inputUser.getText().toString().trim();
String password = inputPassword.getText().toString().trim();
// Check for empty data in the form
if (username.trim().length() > 0 && password.trim().length() > 0) {
Map<String,String> params = new HashMap<>();
params.put("username", inputUser.getText().toString());
params.put("password", inputPassword.getText().toString());
sendPostRequest(params);
} else {
// Prompt user to enter credentials
Toast.makeText(getApplicationContext(),
"Silahkan Masukan Username dan Password!", Toast.LENGTH_LONG)
.show();
}
}
});
public void sendPostRequest(Map<String, String> params) {
showDialog();
RequestQueue queue = Volley.newRequestQueue(this);
String url = "http://www.chris-chris.webege.com/login.php";
mCustomRequest = new CustomRequest(Request.Method.POST,
url, params, new Response.Listener<JSONObject>() {
#Override
public void onResponse(JSONObject response) {
Intent intent = new Intent(Login.this,
Coba.class);
startActivity(intent);
finish();
}
}, new Response.ErrorListener() {
#Override
public void onErrorResponse(VolleyError error) {
Log.d("Error", error.getMessage());
hidepDialog();
Toast.makeText(Login.this, "Belum Terhubung Internet! ", Toast.LENGTH_SHORT).show();
}
});
mCustomRequest.setRetryPolicy(new DefaultRetryPolicy(Template.VolleyRetryPolicy.SOCKET_TIMEOUT,
Template.VolleyRetryPolicy.RETRIES, DefaultRetryPolicy.DEFAULT_BACKOFF_MULT));
queue.add(mCustomRequest);
}
There are two conditions to convert a string to JSONObject :
1 . The string should be in proper Json format .
2 . Put code in try catch block .
Example:
String jsonString = "{"status":"1","message":"Login successfully","data":{"uid":"1","email":"baleshwar#gmail.com","password":"202cb962ac59075b964b07152d234b70","name":"","role":"1","gender":"","address":"","image":"","is_active":"0","last_login":"0000-00-00 00:00:00","device_id":"0","created_at":"2015-06-03 06:01:02","updated_at":"2015-06-03 11:01:02","location":"","dob":"0000-00-00","descriptions":""}}"
Now convert this string to JSONObject
try{
JSONObject jsonResponse = new JSONObject(result);
}catch(Exception e){
e.printStackTrace();
}
Try this,
If you call your service and try to paste that code inside your isSucsess part
JSONObject jObject = jsonObject.getJSONObject("jsonobjectname");
tvTitle.setText(jObject.getString("your string name"));
Related
public class Login extends AppCompatActivity {
private static String LOGIN_URL = "http://172.26.154.132:75";
private EditText username;
private EditText password;
private Button buttonLogin;
private ProgressBar loading;
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_login);
username = (EditText) findViewById(R.id.input_email1);
password = (EditText) findViewById(R.id.input_password);
buttonLogin = (Button) findViewById(R.id.btn_login);
loading = findViewById(R.id.loading);
buttonLogin.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View v) {
String mEmail = username.getText().toString().trim();
String mPass = password.getText().toString().trim();
if(!mEmail.isEmpty() || !mPass.isEmpty()){
Login1(mEmail, mPass);
} else {
username.setError("Please insert email");
password.setError("Please insert password");
}
}
});
}
private void Login1(final String username, final String password) {
loading.setVisibility(View.VISIBLE);
buttonLogin.setVisibility(View.GONE);
StringRequest stringRequest = new StringRequest(Request.Method.POST, LOGIN_URL,
new Response.Listener<String>() {
#Override
public void onResponse(String response) {
try {
JSONObject jsonObject = new JSONObject(response);
String success = jsonObject.getString("data");
JSONArray jsonArray = jsonObject.getJSONArray("data");
if (success.equals("data")) {
for (int i = 0; i < jsonArray.length(); i++) {
JSONObject object = jsonArray.getJSONObject(i);
Intent intent = new Intent(Login.this, MainActivity.class);
startActivity(intent);
loading.setVisibility(View.GONE);
}
}
} catch (JSONException e) {
e.printStackTrace();
loading.setVisibility(View.GONE);
buttonLogin.setVisibility(View.VISIBLE);
Toast.makeText(Login.this, "error" + e.toString(), Toast.LENGTH_SHORT).show();
}
}
}, new Response.ErrorListener() {
#Override
public void onErrorResponse(VolleyError error) {
loading.setVisibility(View.GONE);
buttonLogin.setVisibility(View.VISIBLE);
Toast.makeText(Login.this, "error" + error.toString(), Toast.LENGTH_SHORT).show();
}
})
{
#Override
protected Map<String, String> getParams() throws AuthFailureError {
Map<String, String> params = new HashMap<>();
params.put("username", username);
params.put("password", password);
return params;
}
};
RequestQueue requestQueue = Volley.newRequestQueue(this);
requestQueue.add(stringRequest);
}
}
The response:
{
"status": true,
"message": "User login successful.",
"data": [
{
"sno": "165",
"username": "khushboo.iit#gmail.com",
"user_id_generate": "khushbu#Paswan2018782",
"password": "25f9e794323b453885f5181f1b624d0b",
"is_verified": "1",
"hash": "",
"user_type": "icb_user",
"user_role": "admin"
}
]
}
If your API successfully return data then the problem is JSON parsing. JSON data not parsed successfully. Because "data" contains an array not a single String value.
Try this
try {
JSONObject jsonObject = new JSONObject(response);
boolean success = jsonObject.getBoolean("status");
JSONArray jsonArray = jsonObject.getJSONArray("data");
if (success) {
for (int i = 0; i < jsonArray.length(); i++) {
JSONObject object = jsonArray.getJSONObject(i);
Intent intent = new Intent(Login.this, MainActivity.class);
startActivity(intent);
loading.setVisibility(View.GONE);
}
}
} catch (JSONException e) {
e.printStackTrace();
loading.setVisibility(View.GONE);
buttonLogin.setVisibility(View.VISIBLE);
Toast.makeText(Login.this, "error" + e.toString(), Toast.LENGTH_SHORT).show();
}
I didnt understood question properly but i think i know what you meant.
As there are two functions one is for success and one is for failure you can handle cases like this..
Use JSONObjectRequest instead of string request, It will return you a JSONObject string instead of a string response. Or You can convert the string into a JSONObject like this
JSONObject response = new JSONObject(response)
and then you can parse the jsonObject like this.
if(respose.optString("status")==true)
//success
else
//failed
If you want to print the error msg which is coming from server... do it like this:
error.networkResponse.statusCode
error.networkResponse.message
I am not sure i should use which type of content to POST to the api because I am very new to this developing world.
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_register);
button = (Button)findViewById(R.id.reg_btn_sign_up);
btnCancel = (Button)findViewById(R.id.reg_button_cancel);
Email = (EditText)findViewById(R.id.reg_email);
Name = (EditText)findViewById(R.id.reg_name);
Pass = (EditText)findViewById(R.id.reg_pass);
ConPass = (EditText)findViewById(R.id.reg_confirm_pass);
button.setOnClickListener(new View.OnClickListener(){
#Override
public void onClick(View v) {
email = Email.getText().toString();
name = Name.getText().toString();
password = Pass.getText().toString();
conPass = ConPass.getText().toString();
JSONObject jsonBody = new JSONObject();
try {
jsonBody.put("username", email);
jsonBody.put("password", password);
jsonBody.put("name", name);
} catch (JSONException e) {
e.printStackTrace();
}
final String mRequestBody = jsonBody.toString();
StringRequest stringRequest = new StringRequest(Request.Method.POST, reg_url, new Response.Listener<String>() {
#Override
public void onResponse(String response) {
try {
JSONArray jsonArray = new JSONArray(response);
JSONObject jsonObject = jsonArray.getJSONObject(0);
String status = jsonObject.getString("status");
String result = jsonObject.getString("result");
builder.setTitle("Server Response...");
builder.setMessage(result);
} catch (JSONException e){
e.printStackTrace();
}
}
}, new Response.ErrorListener() {
#Override
public void onErrorResponse(VolleyError error) {
}
})
{
#Override
public byte[] getBody() throws AuthFailureError {
try {
return mRequestBody == null ? null : mRequestBody.getBytes("utf-8");
} catch (UnsupportedEncodingException e) {
e.printStackTrace();
return null;
}
}
#Override
public String getBodyContentType() {
return "application/json; charset=utf-8";
}
};
MySingleton.getmInstance(RegisterActivity.this).addRequestQueue(stringRequest);
}
});
}
}
This is the log I get in logcat:
W/System.err: org.json.JSONException: Value
{"status":0,"result":"Access restricted"} of type org.json.JSONObject
cannot be converted to JSONArray
I do it correctly in POSTMAN but I failed to get the result I want in android.
API added in command.
try this
public void login(final String user, final String pass) {
Log.e("Constant.KEY_URL", String.valueOf(Constant.KEY_URL));
StringRequest stringRequest = new StringRequest(Request.Method.POST, Constant.KEY_URL,
new Response.Listener<String>() {
#Override
public void onResponse(String response) {
//you will get your response in log
Log.e("response", response);
if (user.equals("") || pass.equals("")) {
Toast.makeText(getApplicationContext(), "username or password is empty", Toast.LENGTH_LONG).show();
} else if (!response.equals("empty")) {
Log.e("isempty", "yes");
try {
JSONArray array = new JSONArray(response);
for (int i = 0; i < array.length(); i++) {
JSONArray array1 = array.getJSONObject(i).getJSONArray("data");
for (int j = 0; j < array1.length(); j++) {
startActivity(intent);
}
}
} catch (JSONException e) {
e.printStackTrace();
}
} else {
Log.e("isempty", "else");
Toast.makeText(getApplicationContext(), "Username or password is incorrect", Toast.LENGTH_LONG).show();
}
}
},
new Response.ErrorListener() {
#Override
public void onErrorResponse(VolleyError error) {
Toast.makeText(getApplicationContext(), "username or password is empty", Toast.LENGTH_LONG).show();
// Toast.makeText(getApplicationContext(), "Invalid username or password", Toast.LENGTH_SHORT).show();
Log.e("Error", "msg==>" + error);
}
}) {
protected Map<String, String> getParams() throws AuthFailureError {
Map<String, String> reqMap = new LinkedHashMap<>();
reqMap.put("username", user);
reqMap.put("password", pass);
reqMap.put("method", "login");
Log.e("request","login" + reqMap);
return reqMap;
}
};
stringRequest.setRetryPolicy(new DefaultRetryPolicy(DefaultRetryPolicy.DEFAULT_TIMEOUT_MS * 30, DefaultRetryPolicy.DEFAULT_MAX_RETRIES, DefaultRetryPolicy.DEFAULT_BACKOFF_MULT));
if (requestQueue == null) {
requestQueue = Volley.newRequestQueue(getApplicationContext());
}
requestQueue.add(stringRequest);
stringRequest.setTag("TAG");
}
call this login method on your button click event
btnlogin.setOnClickListener(new View.OnClickListener()
{
#Override
public void onClick(View view) {
user = editusername.getText().toString().trim();
pass = editpassword.getText().toString().trim();
login(user, pass);
}
});
I'm assuming that you are doing sign up function using volley request response..Relate to my code which i have used for login purpose,you can change it according to your needs..Hope it helps
The response you are getting is JSONObject and not JSONArray
try following code in onResponse method:
try {
JSONObject jsonObject = new JSONObject (response);
String status = jsonObject.getString("status");
String result = jsonObject.getString("result");
builder.setTitle("Server Response...");
builder.setMessage(result);
} catch (JSONException e){
e.printStackTrace();
}
Your are trying to parse an array from your response but you are getting an JSONObject.
So first change this line when you get the response
JSONObject jsonObject = new JSONObject(response);
and check the status
if(jsonObject.getString("status").equalsIgnoreCase("0")){
// show error message or whatever
}else if(jsonObject.getString("status").equalsIgnoreCase("1")){
// then parse your array if response has it
}
Use this
JSONObject jsonObject = new JSONObject (response.toString());
Instead of
JSONArray jsonArray = new JSONArray(response);
JSONObject jsonObject = jsonArray.getJSONObject(0);
In my project, i pass the firstname of a user in a params from the JSONobject request. It would then get the response and fill the textviews. however i cant figure out why my code does not work.I checked my php and it works fine when i put a predefined firstname in it, so i ruled out a web service problem. does it get the response first and then pass the params? please help
public class ProfileActivity extends AppCompatActivity {
TextView Username, Firstname, Lastname, Birthdate, Barangay;
String firstname;
String json_url = "http://localhost/android/getprofileinfo.php";
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_profile);
Username = (TextView)findViewById(R.id.usernameprofile);
Firstname = (TextView)findViewById(R.id.firstnameprofile);
Lastname = (TextView)findViewById(R.id.lastnameprofile);
Birthdate = (TextView)findViewById(R.id.birthdayprofile);
Barangay = (TextView)findViewById(R.id.barangayprofile);
final Bundle bundle = getIntent().getExtras();
firstname = bundle.getString(firstname);
JsonObjectRequest jsonObjectRequest = new JsonObjectRequest(Request.Method.POST, json_url, (String) null,
new Response.Listener<JSONObject>() {
#Override
public void onResponse(JSONObject response) {
try {
Username.setText(response.getString("username"));
Firstname.setText(response.getString("firstname"));
Lastname.setText(response.getString("lastname"));
Birthdate.setText(response.getString("birthdate"));
Barangay.setText(response.getString("barangay"));
}
catch(JSONException e){
e.printStackTrace();
}
}
}, new Response.ErrorListener() {
#Override
public void onErrorResponse(VolleyError error) {
Toast.makeText(ProfileActivity.this, "Something went wrong", Toast.LENGTH_SHORT).show();
error.printStackTrace();
} //end of method onErrorResponse
})
{
#Override
protected Map<String, String> getParams() throws AuthFailureError {
Map<String, String> params = new HashMap<String, String>();
params.put("firstname", firstname);
return params;
}
};
MySingleton.getmInstance(ProfileActivity.this).addTorequestque(jsonObjectRequest);
}
}
this is the getpropileinfo.php
<?php
$firstname =$_POST["firstname"];
define('HOST','localhost');
define('USER','root');
define('PASS','');
define('DB','mydb');
$con = mysqli_connect(HOST,USER,PASS,DB) or die('Unable to Connect');
$sql = "SELECT username,firstname,lastname,birthdate,barangay FROM users
WHERE firstname LIKE '".$firstname."'; ";
$result = mysqli_query($con, $sql);
if(mysqli_num_rows($result) > 0)
{
$row = mysqli_fetch_assoc($result);
echo json_encode(array("username"=>$row['username'],
"firstname"=>$row['firstname'],
"lastname"=>$row['lastname'], "birthdate"=>$row['birthdate'],
"barangay"=>$row['barangay']));
}
?>
You are not properly taking the getExtras(), provide the key name which you pass using putExtra() from your calling activity, like this
In the calling activity pass intent like
Intent i = new Intent(FirstActivity.this, ProfileActivity.class);
String strName = "some_name";
i.putExtra("key_username", strName);
startActivity(i);
Then in ProfileActivity,
final Bundle bundle = getIntent().getExtras();
firstname = bundle.getString("key_username");
Convert to JsonArrayRequest
JsonArrayRequest jsonArrayRequest = new JsonArrayRequest(Request.Method.POST, json_url, (String) null,
new com.android.volley.Response.Listener<JSONArray>() {
#Override
public void onResponse(JSONArray response) {
try {
JSONObject person = (JSONObject) response
.get(0);
Username.setText(person.getString("username"));
Firstname.setText(person.getString("firstname"));
Lastname.setText(person.getString("lastname"));
Birthdate.setText(person.getString("birthdate"));
Barangay.setText(person.getString("barangay"));
} catch (JSONException e) {
e.printStackTrace();
Toast.makeText(getApplicationContext(),
"Error: " + e.getMessage(),
Toast.LENGTH_LONG).show();
}
}
}, new com.android.volley.Response.ErrorListener() {
#Override
public void onErrorResponse(VolleyError error) {
Toast.makeText(ProfileActivity.this, "Something went wrong", Toast.LENGTH_SHORT).show();
error.printStackTrace();
} //end of method onErrorResponse
})
{
#Override
protected Map<String, String> getParams() throws AuthFailureError {
Map<String, String> params = new HashMap<String, String>();
params.put("firstname", firstname);
return params;
}
};
May be its issue with your localhost, Go through Genymotion is using your PC IP address. to get your IP address go to:
start -> cmd -> ipconfig
then search for IPv4, copy the IP and paste it in your URL. It should looks like the following:
String YourURL = "http://192.168.0.106:8888/android/getprofileinfo.php";
Hope this works too for you.
Inside the method parameters, remove the string casting for the json object.
null instead of (String) null.
Change your JSONRequest to a StringRequest.
I am working on android project and my web service successfully giving response in postman as I mention response below. I am getting below error after getting response from my API. I am not doing this types of web service call first time but don't know why this happening. How can I achieve this ?
web service response in postman -
[
{
"emp_id": 43065,
"emp_name": "Rahul Bhandari",
"username": "43065",
"password": null
}
]
Error -
org.json.JSONException: Value [{"emp_id":43065,"emp_name":"Rahul Bhandari","username":"43065","password":null}] of type org.json.JSONArray cannot be converted to JSONObject
Volley Code -
public void apiCall(final String email, final String password) {
processArray = new ArrayList<String>();
HashMap<String, String> params = new HashMap<String, String>();
params.put("username", email);
params.put("password", password);
JsonObjectRequest request_json = new JsonObjectRequest(AppConfig.login, new JSONObject(params),
new Response.Listener<JSONObject>() {
#Override
public void onResponse(JSONObject response) {
if (mStatusCode == 200) {
try {
loginResult = new JSONArray(response.toString());
try {
if (loginResult != null) {
for (int i = 0; i < loginResult.length(); i++) {
JSONObject obj = loginResult.getJSONObject(i);
// SQLite database handler
db = new SQLiteHandler(LoginActivity.this);
// Session manager
session = new SessionManager(LoginActivity.this);
session.setLogin(true);
// Inserting row in users table
db.addUser(obj.getString("username"), obj.getString("emp_name"), obj.getString("emp_id"), obj.getString("emp_designation"), obj.getString("emp_location"));
Intent intent = new Intent(LoginActivity.this, SelectAuditActivity.class);
startActivity(intent);
finish();
Toast.makeText(LoginActivity.this, "Successfull login...", Toast.LENGTH_SHORT).show();
}
} else {
Toast.makeText(LoginActivity.this, "Invalid login credential...", Toast.LENGTH_SHORT).show();
}
} catch (JSONException e) {
e.printStackTrace();
}
} catch (JSONException e) {
e.printStackTrace();
}
//Process os success response
} else {
Toast.makeText(LoginActivity.this, "Oops sorry something went wrong...", Toast.LENGTH_SHORT).show();
}
//Process os success response
}
}, new Response.ErrorListener() {
#Override
public void onErrorResponse(VolleyError error) {
VolleyLog.e("Error: ", error.getMessage());
}
}) {
#Override
protected Response<JSONObject> parseNetworkResponse(NetworkResponse response) {
mStatusCode = response.statusCode;
return super.parseNetworkResponse(response);
}
};
;
// add the request object to the queue to be executed
AppController.getInstance().addToRequestQueue(request_json);
}
JsonArrayRequest request_json = new JsonArrayRequest(AppConfig.login, new JSONArray(params),
new Response.Listener<JSONArray>() {
#Override
public void onResponse(JSONArray response) {
I think you have to replace JsonObjectRequest with JsonArrayRequest once try replacing them like above i did not tried this but hope it helps you.
Your response is a json array
[
{
"emp_id": 43065,
"emp_name": "Rahul Bhandari",
"username": "43065",
"password": null
}
]
but you are making JsonObjectRequest , do a JsonArrayRequest instead
EDIT:
I see you post body is a Json object and you cannot directly send a Json object in JsonArrayRequest , so you have to send the body using getBody() method
example request
JsonArrayRequest jsObjRequest = new JsonArrayRequest
(requestMethod, url, null, new Response.Listener<JSONArray>() {
#Override
public void onResponse(JSONArray response) {
//do some thing with response
}
}, new Response.ErrorListener() {
#Override
public void onErrorResponse(VolleyError error) {
// handelErrorResponse
}
}) {
#Override
public Map<String, String> getHeaders() throws AuthFailureError {
return setHeaders();
}
#Override
public byte[] getBody() {
String body;
// convert your json object to string and send it
body= yourJsonobject.toString();
return body.getBytes();
}
#Override
protected Response<JSONArray> parseNetworkResponse(NetworkResponse response) {
getHeader(response);
return super.parseNetworkResponse(response);
}
};
addToRequestQueue(jsObjRequest);
These square brackets [ {...}, {...},.. ] represent for a JSONArray. So if your array have only one items, Change JsonObjectRequest to JsonArrayRequest which will return an JSONArray then get the first item from this array.
JsonArrayRequest req = new JsonArrayRequest(urlJsonArry,
new Response.Listener<JSONArray>() {
#Override
public void onResponse(JSONArray response) {
JSONObject result = response.get(0);
}
}
You're making a request using the object JsonObjectRequest, this mean that your request are expecting a json in the object format like:
{ a: "a", b: "b" }
but your service is responding with a json array that look like:
[{a:"a", b:"b"} , {a:"a1", b:"b1"}]
so, in order to get rid of your error change the way you make your request using JsonArrayRequest
Use this code
if (loginResult != null) {
//for (int i = 0; i < loginResult.length(); i++) {
JSONObject obj = loginResult.getJSONObject(0);
//JSONObject obj = loginResult.getJSONObject(i);
// SQLite database handler
db = new SQLiteHandler(LoginActivity.this);
// Session manager
session = new SessionManager(LoginActivity.this);
session.setLogin(true);
// Inserting row in users table
/*db.addUser(obj.getString("username"), obj.getString("emp_name"), obj.getString("emp_id"), obj.getString("emp_designation"), obj.getString("emp_location"));*/
db.addUser(obj.getString("username"), obj.getString("emp_name"), obj.getString("emp_id"),"","");
Intent intent = new Intent(LoginActivity.this, SelectAuditActivity.class);
startActivity(intent);
finish();
Toast.makeText(LoginActivity.this, "Successfull login...",
Toast.LENGTH_SHORT).show();
//}
} else {
Toast.makeText(LoginActivity.this, "Invalid login credential...", Toast.LENGTH_SHORT).show();
}
return this only from web services
{
"emp_id": 43065,
"emp_name": "Rahul Bhandari",
"username": "43065",
"password": null
}
I am getting this in my Json method.
I am trying to get information from my server and mysql database and then display it in my username text view.
This is my Json Method. It throws the index out of range error.
private void showJSON(String response) {
String username = "";
try {
JSONObject jsonObject = new JSONObject(response);
JSONArray result = jsonObject.getJSONArray(Constantss.JSON_ARRAY);
JSONObject profileData = result.getJSONObject(0);
username = profileData.getString(Constantss.USERNAME);
System.out.println("first" + username);
} catch (JSONException e) {
e.printStackTrace();
}
usernameView.setText(username);
System.out.println("second" + username);
}
Probably not needed but this is how I am getting my data, It works fine I am able to retrieve the Id and also run the php code to give me the username.
private void getData() {
class lata extends AsyncTask<String, Void, String> {
#Override
protected String doInBackground(String... params) {
CognitoCachingCredentialsProvider credentialsProvider = new CognitoCachingCredentialsProvider(
getApplicationContext(), //Context
"us-east--------------", //Identity Pool ID
Regions.US_EAST_1 // Region
//Now we retrieve
);
// return null;
String identityID = credentialsProvider.getIdentityId();
Log.d("LogTag", "my ID is" + identityID);
String id = identityID;
String userid = identityID;
System.out.println("Id is" + identityID);
System.out.println("Id tis" + id);
String url = Constantss.PROFILE_URL + identityID;
StringRequest stringRequest = new StringRequest(url, new Response.Listener<String>() {
#Override
public void onResponse(String response) {
showJSON(response);
}
},
new Response.ErrorListener() {
#Override
public void onErrorResponse(VolleyError error) {
Toast.makeText(Profile.this, error.getMessage().toString(), Toast.LENGTH_SHORT).show();
}
});
RequestQueue requestQueue = Volley.newRequestQueue(Profile.this);
requestQueue.add(stringRequest);
return identityID;
}
}
lata pasta = new lata();
pasta.execute();
}
Probably the length of your array is 0. Please check it.
You can try verifying the response var in
private void showJSON(String response) {
Is not empty
Use Gson to decode the json will be much more convenient than the way you did , and obviously the JSONArray result's length is 0