Run activity twice (instead of once) to get value from getter - java

When tapping an image (from a previous activity) I get to this activity (where I pass the clientid) that reads a JSONArray and use a setter to set the nick.
I then use a getter to do a textview setText.
The problem is that the first time no nick is set. When I go back to the previous activity and tap the same image again, only then the nick is set.
Why isn't the nick displayed from the first time.
(ps: I'm quite new to Java/Android Studio)
package com.smartvibes.smartbeat;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.widget.TextView;
import com.android.volley.Request;
import com.android.volley.RequestQueue;
import com.android.volley.Response;
import com.android.volley.VolleyError;
import com.android.volley.toolbox.JsonObjectRequest;
import com.android.volley.toolbox.Volley;
import org.json.JSONException;
import org.json.JSONObject;
public class profileViewActivity extends AppCompatActivity {
RequestQueue rs;
String url, id, nick, age, city, mainpic, numpics, extrapic0, extrapic1, extrapic2, extrapic3, extrapic4, extrapic5;
TextView profileIntro;
static String pnick;
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_profile_view);
Bundle getProfileId = getIntent().getExtras();
if (getProfileId == null) {
return;
}
String profileid = getProfileId.getString("profileid");
url = "https://www.smartvibes.be/profiles/api/profileview.php?id=" + profileid;
rs = Volley.newRequestQueue(this);
sendjsonrequest();
profileIntro = (TextView) findViewById(R.id.profileIntro);
profileIntro.setText(getPnick());
}
public void sendjsonrequest() {
JsonObjectRequest jsonObjectRequest = new JsonObjectRequest(Request.Method.GET, url, null, new Response.Listener<JSONObject>() {
#Override
public void onResponse(JSONObject response) {
try {
setPnick(response.getString("nick"));
} catch (JSONException e) {
e.printStackTrace();
}
}
}, new Response.ErrorListener() {
#Override
public void onErrorResponse(VolleyError error) {
}
});
rs.add(jsonObjectRequest);
}
public static void setPnick(String nick) {
pnick = nick;
}
public static String getPnick(){
return pnick;
}
}

Because sendjsonrequest is an async call
You need to update textView in onResponse Method itself, like below
setPnick(response.getString("nick"));
profileIntro.setText(getPnick());

Related

How can I solve the register button to pass the form to mysql database and direct me to login page on android studio using java?

I have started mobile app programming using java on android studio, I created a login and register activity for the user and the backend using PHP MySQL to save the details and retrieve them while logging in. When testing register to fill the form and click the button it does not do anything. At first, it brought the error "volley timeout error and I fixed it using the retry policy and fixed the post variables in PHP. But still, it doesn't show any error nor direct me to login page or no changes in the database.
I tried to change the URL from my PC's IP to the emulator's and the server database address but to no avail. I've tried to see what is the error but I'm going through circles. my xamp is also running. I have tried to debug the login activity first and by that, I'll be able to know what error occurs there
Register Activity
package com.example.artisanapplication;
import androidx.annotation.Nullable;
import androidx.appcompat.app.AppCompatActivity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;
import android.widget.Toast;
import com.android.volley.AuthFailureError;
import com.android.volley.Request;
import com.android.volley.RequestQueue;
import com.android.volley.Response;
import com.android.volley.RetryPolicy;
import com.android.volley.VolleyError;
import com.android.volley.toolbox.StringRequest;
import com.android.volley.toolbox.Volley;
import java.util.HashMap;
import java.util.Map;
public class RegisterActivity extends AppCompatActivity {
TextView loglink;
private EditText etid, etname, etmob, etpassword, etpassword2, etemail;
private TextView tvStatus;
private Button btnregister;
private String URL = "http://192.168.0.13:8080/artisan_system/register.php";
private String id, fname, mobileno, password, reenterpass, email;
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_register);
etid = findViewById(R.id.etid);
etname = findViewById(R.id.etname);
etmob = findViewById(R.id.etmob);
etpassword = findViewById(R.id.etpassword);
etpassword2 = findViewById(R.id.etpassword2);
etemail = findViewById(R.id.etemail);
tvStatus = findViewById(R.id.tvStatus);
btnregister = findViewById(R.id.btnregister);
id = fname = mobileno = password = reenterpass = email = "";
loglink = findViewById(R.id.loginlink);
}
public void save(View view) {
id = etid.getText().toString().trim();
fname = etname.getText().toString().trim();
mobileno = etmob.getText().toString().trim();
password = etpassword.getText().toString().trim();
reenterpass = etpassword2.getText().toString().trim();
email = etemail.getText().toString().trim();
if(!password.equals(reenterpass)) {
Toast.makeText(this, "Password should be the same", Toast.LENGTH_SHORT).show();
}
else if(!id.equals("") && !fname.equals("") && !mobileno.equals("") && !password.equals("") && !email.equals("")) {
StringRequest stringRequest = new StringRequest(Request.Method.POST, URL, new Response.Listener<String>() {
#Override
public void onResponse(String response) {
if (response.equals("success")) {
tvStatus.setText("Successfully registered");
btnregister.setClickable(false);
} else if (response.equals("failure")) {
tvStatus.setText("Something went wrong!");
}
}
}, new Response.ErrorListener() {
#Override
public void onErrorResponse(VolleyError error) {
Toast.makeText(getApplicationContext(), error.toString().trim(), Toast.LENGTH_SHORT).show();
}
}){
#Nullable
#Override
protected Map<String, String> getParams() throws AuthFailureError {
Map<String, String> data = new HashMap<>();
data.put("id", id);
data.put("fname",fname );
data.put("mobileno",mobileno );
data.put("password", password);
data.put("email",email);
return data;
}
};
RequestQueue requestQueue = Volley.newRequestQueue(getApplicationContext());
requestQueue.add(stringRequest);
}
}
public void login(View view) {
Intent intent = new Intent(this, LoginActivity.class);
startActivity(intent);
finish();
}
}
Register.php
<?php
if(isset($_POST['id']) && isset($_POST['fname']) && isset($_POST['mobileno']) && isset($_POST['password']) && isset($_POST['email'])) {
require_once "connection.php";
require_once "validate.php";
$id = validate($_POST['id']);
$fname = validate($_POST['fname']);
$mobileno = validate($_POST['mobileno']);
$password = validate($_POST['password']);
$email = validate($_POST['email']);
$sql = "insert into register values('$id', '$fname', '$mobileno', '" . md5($password) . "', '$email')";
echo $sql;
if(!$conn->query($sql)) {
echo "Failure";
} else {
echo "Success";
}
}
?>
login activity
package com.example.artisanapplication;
import androidx.annotation.Nullable;
import androidx.appcompat.app.AppCompatActivity;
import android.content.Intent;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;
import android.widget.Toast;
import com.android.volley.AuthFailureError;
import com.android.volley.Request;
import com.android.volley.RequestQueue;
import com.android.volley.Response;
import com.android.volley.VolleyError;
import com.android.volley.toolbox.StringRequest;
import com.android.volley.toolbox.Volley;
import java.util.HashMap;
import java.util.Map;
public class LoginActivity extends AppCompatActivity {
TextView forgetbtn;
Button login;
private EditText etid, etpassword;
private String id, password;
private String URL = "https://10.0.2.2/artisan_system/login.php";
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_login);
id = password = "";
forgetbtn = findViewById(R.id.forgetbtn);
etid = findViewById(R.id.id_no);
etpassword = findViewById(R.id.password);
forgetbtn.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View view) {
Intent i = new Intent(LoginActivity.this, ForgotPassActivity.class);
startActivity(i);
}
});
}
public void login(View view) {
id = etid.getText().toString().trim();
password = etpassword.getText().toString().trim();
if(!id.equals("") && !password.equals("")) {
StringRequest stringRequest = new StringRequest(Request.Method.POST, URL, new Response.Listener<String>() {
#Override
public void onResponse(String response) {
Log.d("res", response);
//if response state succes then create an intent object and launch success with an intent
if (response.equals("success")) {
Intent intent = new Intent(LoginActivity.this, HomeScreen.class);
startActivity(intent);
finish();
}
else if(response.equals("failure")) {
Toast.makeText(LoginActivity.this, "Invalid login", Toast.LENGTH_SHORT).show();
}
}
}, new Response.ErrorListener() {
#Override
public void onErrorResponse(VolleyError error) {
Toast.makeText(LoginActivity.this, error.toString().trim(), Toast.LENGTH_SHORT).show();
}
}){
#Nullable
#Override
protected Map<String, String> getParams() throws AuthFailureError {
Map<String, String> data = new HashMap<>();
data.put("id", id);
data.put("password", password);
return data;
}
};
RequestQueue requestQueue = Volley.newRequestQueue(getApplicationContext());
requestQueue.add(stringRequest);
}else{
Toast.makeText(this, "Fields cannot be empty", Toast.LENGTH_SHORT).show();
}
}
public void register(View view) {
Intent intent = new Intent(this, RegisterActivity.class);
startActivity(intent);
finish();
}
}

JAVA having trouble retrieving volley result variable value in another class

I have two classes in my android Java Project:
one is API which is inside a local android Module Library that has this code
package com.example.validationchecklib;
import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.widget.Toast;
import android.app.Application;
import com.android.volley.Request;
import com.android.volley.RequestQueue;
import com.android.volley.Response;
import com.android.volley.VolleyError;
import com.android.volley.toolbox.JsonArrayRequest;
import com.android.volley.toolbox.Volley;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
public class API extends Application{
public static int result;
public static int resultInApi;
public int checkSubscription(String packageName, String purchaseCode, RequestQueue q) {
String apiUrl = "https://package.evisions.tech/check_validation.php?package_name=" + packageName;
// creating a new variable for our request queue
//RequestQueue queue = Volley.newRequestQueue(getApplicationContext());
// in this case the data we are getting is in the form
// of array so we are making a json array request.
// below is the line where we are making an json array
// request and then extracting data from each json object.
JsonArrayRequest jsonArrayRequest = new JsonArrayRequest(Request.Method.GET, apiUrl, null, new Response.Listener<JSONArray>() {
#Override
public void onResponse(JSONArray response) {
for (int i = 0; i < response.length(); i++) {
//creating a new Json object and getting each
//object from our json array.
try {
// we are getting each json object.
JSONObject responseObj = response.getJSONObject(i);
// now we get our response from API in json object format.
// in below line we are extracting a string with
// its key value from our json object.
// similarly we are extracting all the strings from our json object.
String apiPackage = responseObj.getString("package_name");
String apiPurchaseCode = responseObj.getString("purchase_code");
int apiStatus = responseObj.getInt("status");
if (apiStatus == 1) {
if (apiPackage.equalsIgnoreCase(packageName) && apiPurchaseCode.equalsIgnoreCase(purchaseCode)) {
//subcription status is valid and user inputed data matches with api data
result = 1;
System.out.println("Result in Api = "+result);
break;
}
} else if (apiStatus == 0) {
result = 0;
System.out.println("Result in Api = "+result);
break;
} else {
result = 2;
System.out.println("Result in Api = "+result);
break;
}
} catch (JSONException e) {
e.printStackTrace();
}
}
}
}, new Response.ErrorListener() {
#Override
public void onErrorResponse(VolleyError error) {
result = 3;
System.out.println("Result in Api = Failed to get the data...");
}
});
q.add(jsonArrayRequest);
return result;
}
}
The second class is MainActivity where I want to retrieve the value from the checkSubsccription() method that is on API class but I am getting 0 even when the request from volley has value 1.
You can test the request using this URL: https://package.evisions.tech/check_validation.php?package_name=aaaa
this is the code for MainActivity
package com.example.aaaa;
import androidx.appcompat.app.AppCompatActivity;
import android.content.Intent;
import android.content.SharedPreferences;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;
import android.widget.Toast;
import com.android.volley.RequestQueue;
import com.android.volley.toolbox.Volley;
import com.example.validationchecklib.Subscription;
import com.example.validationchecklib.API;
import java.util.ArrayList;
public class MainActivity extends AppCompatActivity {
//Sample implementation of the Purchase validation android Library
public String packageName, purchaseCode;
public TextView txtPackageName, txtPurchaseCode;
public Button btnResult;
int serverResponse;
public String r;
private ArrayList<Subscription> subscriptionModalArrayList;
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
subscriptionModalArrayList = new ArrayList<>();
txtPackageName = findViewById(R.id.edtPackageName);
txtPurchaseCode = findViewById(R.id.edtPurchaseCode);
btnResult = findViewById(R.id.btnVerify);
RequestQueue queue = Volley.newRequestQueue(this);
API api = new API();
btnResult.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View view) {
packageName = txtPackageName.getText().toString().trim();
purchaseCode = txtPurchaseCode.getText().toString().trim();
serverResponse = api.checkSubscription(packageName,purchaseCode, queue);
System.out.println("Result = "+serverResponse);
if(api.result == 1){
subscriptionModalArrayList.add(new Subscription(packageName,purchaseCode));
Intent intent = new Intent(MainActivity.this, ValidationResult.class);
startActivity(intent);
}
if(api.result == 0){
Toast.makeText(MainActivity.this, "Inactive Subscription", Toast.LENGTH_LONG).show();
System.exit(1);
}
if(serverResponse == 2 || serverResponse == 3){
Toast.makeText(MainActivity.this, "Failed to fetch data from API or other Error...", Toast.LENGTH_LONG).show();
System.exit(1);
}
txtPackageName.setText("");
txtPurchaseCode.setText("");
}
});
}
}
The request you are making is asynchronous and you must wait to get the response from it.
The behavior you are seeing (always returning zero) because the result variable has not been initialized and defaults to zero.
public static int result;
You can pass a callback to your checkSubscription method which will be called when you have a result from the request (either failure or success).
You can do this by defining an interface like so:
public interface Callback {
public void onSuccess(int result);
public void onFailure(String error);
}
And making your activity implement this method:
public class MainActivity extends AppCompatActivity implements Callback {
...
public void onSuccess(int result) {
//Your logic here
}
public void onFailure(String error) {
//Your logic here
}
}
And make sure to pass the activity to your API:
public int checkSubscription(String packageName, String purchaseCode, RequestQueue q, Callback callback) {
.....
callback.onSuccess(result)
public void onErrorResponse(VolleyError error) {
result = 3;
System.out.println("Result in Api = Failed to get the data...");
callback.onError("YOUR_ERROR_MESSAGE");
}
}
Disclaimer : the above code is just a rough outline and should be
tested

Android Studio Java JSON fetching data problem

PLEASE HELP, WHAT IS WRONG WITH MY CODE, IT DISPLAYS NOTHING BUT ZEROS AND NULL
I already search through tutorials, i even copied the whole code but i cant get the data from this API, my textviews on int are returning zeros and my textviews on string are returning null after a press the update button.
here is my api link = api link
here is the result
package com.example.firstapp;
import androidx.appcompat.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;
import android.widget.Toast;
import com.android.volley.Request;
import com.android.volley.RequestQueue;
import com.android.volley.Response;
import com.android.volley.VolleyError;
import com.android.volley.toolbox.JsonObjectRequest;
import com.android.volley.toolbox.Volley;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
public class MainActivity extends AppCompatActivity {
private TextView confirmed, recovered, deaths, country, date;
private RequestQueue mQueue;
private Button update;
private int c,r,d;
private String co,da;
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
confirmed = findViewById(R.id.confirmed);
recovered = findViewById(R.id.recovered);
deaths = findViewById(R.id.deaths);
country = findViewById(R.id.country);
date = findViewById(R.id.date);
update = findViewById(R.id.update);
mQueue = Volley.newRequestQueue(this);
update.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View v) {
jsonParse();
confirmed.setText(String.valueOf(c));
recovered.setText(String.valueOf(r));
deaths.setText(String.valueOf(d));
country.setText(co);
date.setText(da);
}
});
}
private void jsonParse(){
String url = "https://covid-api.mmediagroup.fr/v1/cases?country=Philippines";
JsonObjectRequest request = new JsonObjectRequest(Request.Method.GET, url, null, new Response.Listener<JSONObject>() {
#Override
public void onResponse(JSONObject response) {
try {
JSONArray jsonArray = response.getJSONArray("All");
for (int i = 0; i < jsonArray.length(); i++) {
JSONObject cases = jsonArray.getJSONObject(i);
c = cases.getInt("confirmed");
r = cases.getInt("recovered");
d = cases.getInt("deaths");
co = cases.getString("country");
da = cases.getString("updated");
}
} catch (JSONException e) {
e.printStackTrace();
}
}
}, new Response.ErrorListener() {
#Override
public void onErrorResponse(VolleyError error) {
Toast.makeText(getApplicationContext(),
error.getMessage(),
Toast.LENGTH_LONG).show();
}
});
mQueue.add(request);
}
}
I don't know what is the problem here, can someone help
I already fixed it thank you so much.
my solution is I removed JsonArray.
package com.example.firstapp;
import androidx.appcompat.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;
import android.widget.Toast;
import com.android.volley.Request;
import com.android.volley.RequestQueue;
import com.android.volley.Response;
import com.android.volley.VolleyError;
import com.android.volley.toolbox.JsonObjectRequest;
import com.android.volley.toolbox.Volley;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
public class MainActivity extends AppCompatActivity {
private TextView confirmed, recovered, deaths, country, date;
private RequestQueue mQueue;
private Button update;
private int c,r,d;
private String co,da;
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
confirmed = findViewById(R.id.confirmed);
recovered = findViewById(R.id.recovered);
deaths = findViewById(R.id.deaths);
country = findViewById(R.id.country);
date = findViewById(R.id.date);
update = findViewById(R.id.update);
mQueue = Volley.newRequestQueue(this);
update.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View v) {
jsonParse();
}
});
}
private void jsonParse(){
String url = "https://covid-api.mmediagroup.fr/v1/cases?country=Philippines";
JsonObjectRequest request = new JsonObjectRequest(Request.Method.GET, url, null,
new Response.Listener<JSONObject>() {
#Override
public void onResponse(JSONObject response) {
try{
//JSONArray jsonArray = response.getJSONArray();
for (int i = 0; i < response.length(); i++) {
JSONObject cases = response.getJSONObject("All");
c = cases.getInt("confirmed");
r = cases.getInt("recovered");
d = cases.getInt("deaths");
co = cases.getString("country");
da = cases.getString("updated");
confirmed.setText(String.valueOf(c));
recovered.setText(String.valueOf(r));
deaths.setText(String.valueOf(d));
country.setText(co);
date.setText(da);
}
} catch (JSONException e) {
e.printStackTrace();
}
}
}, new Response.ErrorListener() {
#Override
public void onErrorResponse(VolleyError error) {
Toast.makeText(getApplicationContext(),
error.getMessage(),
Toast.LENGTH_LONG).show();
}
});
mQueue.add(request);
}
}
I replaced
JSONObject cases = jsonArray.getJSONObject(i);
with
JSONObject cases = response.getJSONObject("All");
and removed
JSONArray jsonArray = response.getJSONArray();
because it is not necessary.

Android studio connecting to remote database

I am trying to get an Android Studio app to connect to a remote server hosted on "hostbuddy". Here is the code (when sending data the error is "Connection goes wrong 2") making me guess there is something wrong with the DB_URL. I tried changing the url in many ways, none worked. If it would help I could also post the logcat.
EDIT : I fixed it, i forgot to add the module for the connector for MySQl, works like a charm now ^_^
package com.example.battl.qr2;
import android.content.Intent;
import android.os.AsyncTask;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;
import android.widget.Toast;
import org.w3c.dom.Text;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.Statement;
public class Register extends AppCompatActivity {
TextView textView;
Button button;
EditText editText;
private static final String DB_URL= "jdbc:mysql://mysql6002.site4now.net/db_a37d85_mydb:3306";
private static final String USER = "X";
private static final String PASS = "X";
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_register);
textView=(TextView) findViewById(R.id.textView);
editText=(EditText) findViewById(R.id.editText);
}
public void btnConn(View view)
{
Send objsend = new Send();
objsend.execute("");
}
private class Send extends AsyncTask<String,String,String>
{
String msg = "";
String text = editText.getText().toString();
#Override
protected void onPreExecute() {textView.setText("Please Wait Inserting");}
#Override
protected String doInBackground(String... strings)
{
try
{
Class.forName("com.mysql.jdbc.Driver");
Connection conn = DriverManager.getConnection(DB_URL,USER,PASS);
if(conn == null) {
msg="Connection goes wrong";
} else {
String query = "INSERT INTO ex (col1) VALUES ('"+text+"') ";
Statement stmt = conn.createStatement();
stmt.executeUpdate(query);
msg = "Inserted successfully";
}
conn.close();
}
catch (Exception e)
{
msg="Connection goes wrong 2";
e.printStackTrace();
}
return msg;
}
#Override
protected void onPostExecute(String msg) {textView.setText(msg);}
}
}

return data from method (JSON Array)

I have one method with this url:
String url = "http://brunos.000webhostapp.com/teste/obter_id.php?descricao=" + value;
And i want to return the result of this method.
i have tried the VolleyCallback callback but i cant send the value to the method
package com.example.fabio.domoticaa;
import android.content.Intent;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.widget.EditText;
import com.android.volley.Request;
import com.android.volley.RequestQueue;
import com.android.volley.Response;
import com.android.volley.VolleyError;
import com.android.volley.toolbox.JsonArrayRequest;
import com.android.volley.toolbox.Volley;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
public class Divi_Dispo extends AppCompatActivity {
String x;
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_divi__dispo);
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
final String[] count = new String[1];
final String[] id = new String[1];
Intent intent = getIntent();
String value = intent.getStringExtra("divisao");
final EditText nomediv = (EditText) findViewById(R.id.editText4);
Count(value);
nomediv.setText(x);//want set th result of Count(value)
}
public void Count(String value) {
final String[] count = new String[1];
// Send data
try {
RequestQueue queue = Volley.newRequestQueue(Divi_Dispo.this);
String url = "http://brunos.000webhostapp.com/teste/obter_id.php?descricao=" + value ;
JsonArrayRequest jsonRequest = new JsonArrayRequest
(Request.Method.GET, url, null, new Response.Listener<JSONArray>() {
#Override
public void onResponse(JSONArray response) {
try {
JSONObject jObj = new JSONObject(String.valueOf(response.get(0)));
count[0] = jObj.getString("COUNT(id)");//want return this valor
} catch (JSONException e) {
e.printStackTrace();
}
}
}, new Response.ErrorListener() {
#Override
public void onErrorResponse(VolleyError error) {
error.printStackTrace();
}
});
queue.add(jsonRequest);
} catch (Exception ex) {
} finally {
}
}
public interface VolleyCallback {
void onSuccess(String result);
}
}

Categories