I have to send byte array using Http post method,but in basicnamevalue pair class its gives
me error as the constructor BasicNameValuePair(String, byte[]) is undefined.is any onother way to solved this issue please help me.
AsyncTask :
public void SaveDatandImage() {
Byte[] image1,image2;
new AsyncTask<Void, Void, String>() {
protected void onPreExecute() {
pDialog = new ProgressDialog(DetailsAcceptActivity.this);
pDialog.setTitle("Sending Query");
pDialog.setMessage("Please Wait...");
pDialog.setCancelable(true);
pDialog.show();
};
protected String doInBackground(Void... params) {
String response = null;
List<NameValuePair> nameValuePairs = new ArrayList<NameValuePair>();
Date today = new Date();
nameValuePairs.add(new BasicNameValuePair("name","Name"));
nameValuePairs.add(new BasicNameValuePair("image1",image1));
nameValuePairs.add(new BasicNameValuePair("image2",image2));
if (Common.isInternetConnected(DetailsAcceptActivity.this)) {
try {
response = Common.httpPost(url_make_query, nameValuePairs, new String[] {});
// Jobj=jparser.makeHttpRequest(url_make_query, "POST", nameValuePairs);
Log.v(Common.TAG, "Record respose : " + response);
Intent intent = new Intent(DetailsAcceptActivity.this, LoginActivity.class);
DetailsAcceptActivity.this.finish();
startActivity(intent);
//Toast.makeText(MenuActivity.this,"Record Saved",Toast.LENGTH_SHORT).show();
/*JSONObject jObj = new JSONObject(response);
strRespCode = jObj.getString("success");
strRespMessage=jObj.getString("message");
int success=Jobj.getInt(TAG_SUCCESS);
if(success==1) {
Toast.makeText(MenuActivity.this,"inserted", Toast.LENGTH_SHORT).show();
} else {
Toast.makeText(MenuActivity.this,"Error", Toast.LENGTH_SHORT).show();
}*/
//if(response.e)
} catch (ClientProtocolException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
} else {
//groupMember.setSynced_with_server(StaticMembers.ZERO);
return "NO_NETWORK";
}
return response;
};
protected void onPostExecute(String result) {
if (result != null) {
if(!result.equals("NO_NETWORK")) {
//groupMember.setSynced_with_server(StaticMembers.ONE);
}
//Log.w("strRespMessage= "+strRespMessage, "********");
// Toast.makeText(MenuActivity.this, "Query Sent!!", Toast.LENGTH_LONG).show();
//finish();
}
pDialog.dismiss();
}
}.execute(null, null);
}
PHP Script to accept data from front end
<?php
// array for JSON response
$response = array();
// check for required fields
if (isset($_POST['sender_mobile_no'])) {
$name = $_POST['name'];
$image1= $_POST['image1'];
$image2= $_POST['image2'];
// include db connect class
require_once __DIR__ . '/db_connect.php';
// connecting to db
$db = new DB_CONNECT();
$con = mysqli_connect(DB_SERVER, DB_USER, DB_PASSWORD, DB_DATABASE);
// mysql inserting a new row
$result = mysqli_query($con,"INSERT INTO tbl_query_master(name,image1,image2) VALUES('$name','$sender_name', '$image1', '$image2')");
// check if row inserted or not
if ($result) {
// successfully inserted into database
$response["success"] = 1;
$response["message"] = "Order placed successfully.";
// echoing JSON response
echo json_encode($response);
} else {
// failed to insert row
$response["success"] = 0;
$response["message"] = "Oops! An error occurred.";
// echoing JSON response
echo json_encode($response);
}
} else {
// required field is missing
$response["success"] = 0;
$response["message"] = "Required field(s) is missing";
// echoing JSON response
echo json_encode($response);
}
?>
You can encode your image bytes into String and then send it on server. You can use
String strImage=Base64.encodeToString(image1, Base64.DEFAULT); // image1 is your byte[]
and then set this String in your namevaluepair as
nameValuePairs.add(new BasicNameValuePair("image1",strImage));
In php:
you can decode your string to get bytearray as follows.
$str=$_POST['image1'];
$abc=base64_decode($str);
Related
Below is the method in which I use to send data to PHP
public String createUser(String url,String method,List<Pair<String, String>> params){
//Making Http request
HttpURLConnection httpURLConnection = null;
StringBuffer response = null;
String lineEnd = "\r\n";
try{
if(method.equals("POST")){
URL urlPost = new URL(url);
httpURLConnection = (HttpURLConnection) urlPost.openConnection();
httpURLConnection.setDoOutput(true); //defaults request method to POST
httpURLConnection.setDoInput(true); //allow input to this HttpURLConnection
httpURLConnection.setUseCaches(false);
httpURLConnection.setRequestMethod("POST");
//httpURLConnection.setRequestProperty("Content-Type","application/json");
//httpURLConnection.setRequestProperty("Host", "192.168.0.101");
httpURLConnection.connect();
DataOutputStream wr = new DataOutputStream(httpURLConnection.getOutputStream());
wr.writeBytes(params.toString());
//wr.writeBytes("user_email="+userEmailText);
//wr.writeBytes(lineEnd);
wr.flush(); //flush the stream when we're finished writing to make sure all bytes get to their destination
wr.close();
InputStream is = httpURLConnection.getInputStream();
BufferedReader rd = new BufferedReader(new InputStreamReader(is));
String line;
response = new StringBuffer();
while((line = rd.readLine()) != null) {
response.append(line);
response.append('\r');
}
}
} catch (ProtocolException e) {
e.printStackTrace();
} catch (MalformedURLException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
return response.toString();
}
In my AsyncTask class:
params.add(new Pair<>("user_name", userNameText));
params.add(new Pair<>("user_email", userEmailText));
HttpHandler sh = new HttpHandler();
String jsonStrUserCreation = sh.createUser(url,"POST",params);
System.out.println("userNameText: " + userNameText);
System.out.println("userEmailText: " + userEmailText);
Log.e(TAG, "Response from userCreationURL: " + jsonStrUserCreation);
try{
JSONObject jsonObj = new JSONObject(jsonStrUserCreation);
} catch (JSONException e) {
e.printStackTrace();
}
Below is my PHP code:
<?php
require_once 'connecttodb.php';
$db = new DB();
$con = $db->db_connect();
if(isset($_POST['user_name']) && isset($_POST['user_email'])){
$user_name = $_POST['user_name'];
$user_email = $_POST['user_email'];
$sql = "INSERT INTO user_details(user_name,user_email) VALUES('$user_name','$user_email')";
$run = mysqli_query($con,$sql);
if($run){
$response["success"] = 1;
$response["message"] = "Account successfully created";
echo json_encode($response);
}else{
$response["success"] = 0;
$response["message"] = "Account failed to be created";
echo json_encode($response);
}
}else{
$response["success"] = 2;
$response["message"] = "Failed to run inner code";
echo json_encode($response);
}
The script always return "Failed to run inner code" when I have passed in the values for user_name and user_email.
Found the solution as below. Make sure that your string is in the format below
String urlParameters = "user_name="+userNameText+"&user_email="+userEmailText;
And then call it as below:
sh.createUser(url,urlParameters);
You will see the magic.
I am inserting some values from my android login page to mysql database using php .
login.php
<?php
$con = mysql_connect("localhost","abc","xyz") or die(mysql_error());
mysql_select_db("sync",$con) or die(mysql_error());
$user_name = $_POST['user_name'];
$user_mobile_no = $_POST['user_mobile_no'];
$user_email_id = $_POST['user_email_id'];
$imei_no = $_POST['imei_no'];
$login_date = $_POST['login_date'];
$time = $_POST['time'];
$user_name = 'Navdeep';
$user_mobile_no = '12345678990';
$user_email_id = 'nav#gmail.com';
$imei_no = '1234567890';
$login_date = '24-12-2012';
$time = '01:01:01';
$result = mysql_query("INSERT INTO
login_details(user_name,user_mobile_no,user_email_id,
imei_no,login_date,time)
VALUES('$user_name','$user_mobile_no','$user_email_id',' $imei_no','$login_date','$time')");
if($result)
{
$response["success"] = 1;
$response["message"] = "User Details inserted successfully";
echo json_encode($response);
} else {
$response["success"] = 0;
$response["message"] = "There was an error inserting user details";
echo json_encode($response);
}
mysql_close($con);
?>
When i use $_POST[''] values are getting inserted as blank , but when i hardcode the values it is getting inserted , need some help
Android code :
try{
JSONObject jsonObject = new JSONObject();
jsonObject.put("user_name",userName);
jsonObject.put("user_mobile_no",mobNo);
jsonObject.put("user_email_id",email);
jsonObject.put("imei_no",imeino);
jsonObject.put("login_date",date);
jsonObject.put("time",time);
JSONArray jsonArray = new JSONArray();
jsonArray.put(jsonObject);
String basicAuth = "Device " + new
String(Base64.encode((imeino).getBytes(), Base64.NO_WRAP));
RequestBody body =
RequestBody.create(JSON,String.valueOf(jsonArray));
OkHttpClient okHttpClient = new OkHttpClient();
Request request = new Request.Builder().header("Authorization",
basicAuth).url(url).post(body).build();
Call call = okHttpClient.newCall(request);
call.enqueue(new Callback() {
#Override
public void onFailure(Call call, IOException e) {
e.printStackTrace();
Login.this.runOnUiThread(new Runnable() {
#Override
public void run() {
Toast.makeText(getBaseContext(), "Request to the
server failed", Toast.LENGTH_SHORT).show();
}
});
}
#Override
public void onResponse(Call call, Response response) throws
IOException {
Log.i("response ", "onResponse(): " + response );
StatusLine statusLine = null;
String result = response.body().string();
if(result.equals("") || result.equals(null)){
Log.i("No response", "No response");
}else{
Log.i("Response","Response "+result);
statusLine = StatusLine.get(response);
final int responseCode = statusLine.code;
Log.d("Code:", String.valueOf(responseCode));
}
}
});
}catch (Exception e){
e.printStackTrace();
}
You should send form data request from android.
Replace this
JSONObject jsonObject = new JSONObject();
jsonObject.put("user_name",userName);
jsonObject.put("user_mobile_no",mobNo);
jsonObject.put("user_email_id",email);
jsonObject.put("imei_no",imeino);
jsonObject.put("login_date",date);
jsonObject.put("time",time);
JSONArray jsonArray = new JSONArray();
jsonArray.put(jsonObject);
String basicAuth = "Device " + new
String(Base64.encode((imeino).getBytes(), Base64.NO_WRAP));
RequestBody body =
RequestBody.create(JSON,String.valueOf(jsonArray));
OkHttpClient okHttpClient = new OkHttpClient();
Request request = new Request.Builder().header("Authorization",
basicAuth).url(url).post(body).build();
With
RequestBody formBody = new FormBody.Builder()
.add("user_name",userName)
.add("user_mobile_no",mobNo)
.add("user_email_id",email)
.add("imei_no",imeino)
.add("login_date",date)
.add("time",time)
.build();
String basicAuth = "Device " + new
String(Base64.encode((imeino).getBytes(), Base64.NO_WRAP));
Request request = new Request.Builder().header("Authorization",
basicAuth).url(url).post(formBody).build();
i want to send all contacts with contact name and number in one row in one array in my android application like
john => "+92312xxxxxxx" ,
Right now i'm using namevaluepairs to post two arrays but it's not working like :
public class ContactList extends Activity {
public TextView outputText;
String phoneNumber = null;
String names = null;
String[] keyValue;
String[] kes;
int Count;
String s = "";
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_contact_list);
outputText = (TextView) findViewById(R.id.textView1);
fetchContacts();
//Http connection
InputStream is=null;
List<NameValuePair> nameValuePairs =new ArrayList<NameValuePair>(1);
for (int i = 0; i < Count ; i++)
{
nameValuePairs.add(new BasicNameValuePair("CN[]", keyValue[i]));
nameValuePairs.add(new BasicNameValuePair("names[]",kes[i]));
Log.i("Response", "you sent :" +kes[i]+" :"+ keyValue[i] + "\n ");
}
try{
HttpClient httpclient = new DefaultHttpClient();
HttpPost httppost = new HttpPost("http://192.168.1.107/older/ContactList.php");
httppost.setEntity(new UrlEncodedFormEntity(nameValuePairs));
HttpResponse response = httpclient.execute(httppost);
HttpEntity entity = response.getEntity();
is = entity.getContent();
}
catch(ClientProtocolException e)
{
Log.e("ClientProtocol","Log_tag");
e.printStackTrace();
System.out.println("Excep: "+e);
}
catch(IOException e)
{
Log.e("Log_tag","IOException");
e.printStackTrace();
}
String result = "";
try
{
BufferedReader reader = new BufferedReader(new InputStreamReader(is,"iso-8859-1"),8);
StringBuilder sb = new StringBuilder();
String line = null;
while ((line = reader.readLine()) != null)
{
sb.append(line + "\n");
}
reader.close();
is.close();
result=sb.toString();
Log.i("Response", "result "+ result);
}
catch(Exception e)
{
Log.e("log_tag", "Error converting result "+e.toString());
}
//result = "[{\"0\":\"Muhaimin\",\"1\":\"3\",\"2\":\"o+\"}]";
try
{
JSONArray jArray = new JSONArray(result);
for (int i = 0; i < jArray.length(); i++)
{
s= s +";"+ jArray.getString(i) + "\n";
}
}
catch (Exception e)
{
Log.e("Response", "error fetching indexes" + e);
}
String[] friends= s.split(";");
StringBuffer output = new StringBuffer();
for (int i = 0; i < friends.length; i++)
{
Log.i("List","Your friends namee"+friends[i]);
output.append("\n Your friend's number"+ friends[i]);
}
}
//Fetch Contacts
public void fetchContacts() {
// String email = null;
Uri CONTENT_URI = ContactsContract.Contacts.CONTENT_URI;
String _ID = ContactsContract.Contacts._ID;
String DISPLAY_NAME = ContactsContract.Contacts.DISPLAY_NAME;
String HAS_PHONE_NUMBER = ContactsContract.Contacts.HAS_PHONE_NUMBER;
Uri PhoneCONTENT_URI = ContactsContract.CommonDataKinds.Phone.CONTENT_URI;
String Phone_CONTACT_ID = ContactsContract.CommonDataKinds.Phone.CONTACT_ID;
String NUMBER = ContactsContract.CommonDataKinds.Phone.NUMBER;
// Uri EmailCONTENT_URI = ContactsContract.CommonDataKinds.Email.CONTENT_URI;
//String EmailCONTACT_ID = ContactsContract.CommonDataKinds.Email.CONTACT_ID;
// String DATA = ContactsContract.CommonDataKinds.Email.DATA;
ContentResolver contentResolver = getContentResolver();
Cursor cursor = contentResolver.query(CONTENT_URI, null,null, null, null);
// Loop for every contact in the phone
Count = cursor.getCount();
if (cursor.getCount() > 0) {
keyValue= new String[Count];
kes= new String[Count];
while (cursor.moveToNext()) {
String contact_id = cursor.getString(cursor.getColumnIndex( _ID ));
String name = cursor.getString(cursor.getColumnIndex( DISPLAY_NAME ));
int hasPhoneNumber = Integer.parseInt(cursor.getString(cursor.getColumnIndex( HAS_PHONE_NUMBER )));
if (hasPhoneNumber > 0) {
// Query and loop for every phone number of the contact
Cursor phoneCursor = contentResolver.query(PhoneCONTENT_URI, null, Phone_CONTACT_ID + " = ?", new String[] { contact_id }, null);
while (phoneCursor.moveToNext())
{
int i=0;
String stu = phoneCursor.getString(phoneCursor.getColumnIndex(NUMBER));
phoneNumber +=":"+ stu;
names +=":" + name;
Log.i("List",stu + name +"\n" );
}
phoneCursor.close();
}
}
}
keyValue = phoneNumber.split(":");
kes = names.split(":");
Log.i("List","24th"+keyValue[23]);
Toast.makeText(getApplicationContext(), "99th "+keyValue[909] ,Toast.LENGTH_LONG).show();
}
PHP after receiving contacts will match them and return only those which have a match with database contacts. And then it returns contacts with names
i'm stuck with sending and receving part
Here is php code
<?php
define('DB_HOST', 'localhost');
define('DB_NAME', 'verification');
define('DB_USER','root');
define('DB_PASSWORD','');
// 1. Create a database connection
$connection = mysqli_connect(DB_HOST,DB_USER,DB_PASSWORD);
if (!$connection) {
die("Database connection failed: " . mysqli_error());
}
// 2. Select a database to use
$db_select = mysqli_select_db($connection, DB_NAME);
if (!$db_select) {
die("Database selection failed: " . mysqli_error());
}
$PhoneNum= $_POST["CN"];
$i=0;
$j=0;
$friends = array();
$Invite = array();
unset ($PhoneNum[0]);
foreach ($PhoneNum as $i=> $element){
//or do whatever you need to do to that variable
$query="SELECT Number FROM `user` WHERE Number=$element";
$query_exec = mysqli_query($connection ,$query);
if (!$query_exec)
{ echo mysql_error(); }
ELSE {
if(mysqli_num_rows($query_exec)>0)
{
$friends["$j"]= $PhoneNum[$i];
$j++;
}
else
{
;
}}
}
echo (json_encode($friends));
?>
You'll get a URL now that would look like:
www.example.com/yourscript?CN[]=keyValue1&names[]=key1&CN[]=keyValue2&names[]=key2 etc.. going on untill your whole list has looped.
I doubt that is what your PHP script wants to receive, you probably want to send the POST for each time you increment the loop. But thats just conjecture untill you post more information/code.
Instead send a JSON array as the value of the nameValuePair and convert it to a PHP array using json_decode function in the server side.
I need to delete an item from a list view on android when clicked. The thing is, my table is not on the phone(SQLite), but on the server. So I'm using a PHP code for this.
I have set up an onClickListener.
list.setOnItemClickListener(new AdapterView.OnItemClickListener() {
#Override
public void onItemClick(AdapterView<?> a, View v,int position, long id) {
Show_Alert_box(v.getContext(),
"Please select action.", position);
}
});
public void Show_Alert_box(Context context, String message, int position) {
final int pos = position;
final AlertDialog alertDialog = new AlertDialog.Builder(context)
.create();
//alertDialog.setTitle(getString(R.string.app_name_for_alert_Dialog));
alertDialog.setButton("Delete", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
DBHandlerComments dbhelper = new DBHandlerComments(Comments.this);
SQLiteDatabase db = dbhelper.getWritableDatabase();
try{
JSONObject json2 = JSONParser.makeHttpRequest(urlDelete, "POST", params);
try {
int success = json2.getInt(TAG_SUCCESS);
if (success == 1) {
// successfully updated
Intent i = getIntent();
// send result code 100 to notify about product update
setResult(100, i);
finish();
} else {
// failed to update product
}
} catch (JSONException e) {
e.printStackTrace();
}
//adapter.notifyDataSetChanged();
db.close();
}catch(Exception e){
}
}
});
alertDialog.setButton2("Cancel", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
alertDialog.dismiss();
}
});
alertDialog.setMessage(message);
alertDialog.show();
}
This is my JSONParser's makehttprequest code:
public static JSONObject makeHttpRequest(String url, String method,
List<NameValuePair> params) {
// Making HTTP request
try {
// check for request method
if(method == "POST"){
// request method is POST
// defaultHttpClient
DefaultHttpClient httpClient = new DefaultHttpClient();
HttpPost httpPost = new HttpPost(url);
httpPost.setEntity(new UrlEncodedFormEntity(params));
HttpResponse httpResponse = httpClient.execute(httpPost);
HttpEntity httpEntity = httpResponse.getEntity();
is = httpEntity.getContent();
}else if(method == "GET"){
// request method is GET
DefaultHttpClient httpClient = new DefaultHttpClient();
String paramString = URLEncodedUtils.format(params, "utf-8");
url += "?" + paramString;
HttpGet httpGet = new HttpGet(url);
HttpResponse httpResponse = httpClient.execute(httpGet);
HttpEntity httpEntity = httpResponse.getEntity();
is = httpEntity.getContent();
}
} catch (UnsupportedEncodingException e) {
e.printStackTrace();
} catch (ClientProtocolException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
try {
BufferedReader reader = new BufferedReader(new InputStreamReader(
is, "iso-8859-1"), 8);
StringBuilder sb = new StringBuilder();
String line = null;
//from here
while ((line = reader.readLine()) != null) {
if(!line.startsWith("<", 0)){
if(!line.startsWith("(", 0)){
sb.append(line + "\n");
}
}
}
is.close();
json = sb.toString();
} catch (Exception e) {
Log.e("Buffer Error", "Error converting result " + e.toString());
}
// try parse the string to a JSON object
try {
jObj = new JSONObject(json);
} catch (JSONException e) {
Log.e("JSON Parser", "Error parsing data " + e.toString());
}
// return JSON String
return jObj;
}
`
And this is my PHP code:
$response = array();
if (isset($_POST['id'])) {
$id = $_POST['id'];
// include db connect class
$db = mysql_connect("localhost","tbl","password");
if (!$db) {
die('Could not connect to db: ' . mysql_error());
}
//Select the Database
mysql_select_db("shareity",$db);
// mysql update row with matched id
$result = mysql_query("DELETE FROM comments_activities WHERE id = $id");
// check if row deleted or not
if (mysql_affected_rows() > 0) {
// successfully updated
$response["success"] = 1;
$response["message"] = "Product successfully deleted";
// echoing JSON response
echo json_encode($response);
} else {
// no product found
$response["success"] = 0;
$response["message"] = "No product found";
// echo no users JSON
echo json_encode($response);
}
} else {
// required field is missing
$response["success"] = 0;
$response["message"] = "Required field(s) is missing";
// echoing JSON response
echo json_encode($response);
}
I'm adding the params like this:
params.add(new BasicNameValuePair(KEY_ID, id));
params.add(new BasicNameValuePair(KEY_AID, aid));
params.add(new BasicNameValuePair(KEY_ANAME, an));
params.add(new BasicNameValuePair(KEY_EVENT, ev));
params.add(new BasicNameValuePair(KEY_COMMENT, cb));
params.add(new BasicNameValuePair(KEY_USER, cby));
params.add(new BasicNameValuePair(KEY_TIME, cd));
I don't get any result. Can I know why?
I have noticed that you add unneeded parameters although you just need the id.
This is a simple code for deleting the given id, you can try it. If it worked, the error would be in your android code.
<?php
$servername = "your servername";
$username = "your username";
$password = "your password";
$dbname = "your dbname";
$link = mysql_connect($servername, $username, $password);
mysql_select_db($dbname, $link);
$id=$_POST['id'];
$result = mysql_query("DELETE FROM table_name WHERE id=$id", $link);
$response["success"] = 1;
$response["message"] = "Deleted successfully!";
echo json_encode($response);
?>
Change the servername to your database url and so on the other information.
In my app I have an EditText where the user can add his personal info. When he is done writing, he clicks a button and the corresponding DB column is supposed to be updated, but is not.
Here is my php script :
<?php
$con = mysqli_connect('127.0.0.1','root','lokijuhy1');
mysqli_select_db($con,'twentythree');
$response = array();
if(isset($_POST['about_me']) && isset($_POST['name']) && isset($_POST['uid'])){
$about_me = $_POST['about_me'];
$name = $_POST['name'];
$uid = $_POST['uid'];
$query = "UPDATE profile SET about_me = $about_me WHERE unique_id = $uid";
$result = mysqli_query($con,$query);
if ($result){
$response["success"] = 1;
$response["message"] = "Success";
echo json_encode($response);
} else {
$response["success"] = 0;
$response["message"] = "Table was not Updated";
echo json_encode($response);
}
}else {
$response["success"] = 0;
$response["message"] = "Something is missing!";
echo json_encode($response);
}
?>
And here is my Java code :
class updateProfile extends AsyncTask<String, String, String> {
#Override
protected void onPreExecute() {
super.onPreExecute();
}
protected String doInBackground(String... args) {
// Building Parameters
List<NameValuePair> params = new ArrayList<NameValuePair>();
params.add(new BasicNameValuePair("name",name));
params.add(new BasicNameValuePair("uid",uid));
params.add(new BasicNameValuePair("about_me", about_me));
JSONParser jsonParser = new JSONParser();
JSONObject json = jsonParser.makeHttpRequest(Config.URL_profileUpdate,
"POST", params);
try {
// Checking for SUCCESS TAG
int success = json.getInt("success");
String message = json.optString("message");
if (success == 1) {
System.out.println(message);
}
}catch (JSONException e) {
e.printStackTrace();
}
return null;
protected void onPostExecute(String file_url) {
}
Do you guys have any idea why this happens?
Note : I just noticed that I get a positive JSON response, but the response message is null.