I im using AsyncTask to get string from my server.
My problem is that after AsyncTask is finished my main thread is crashes and the app is
loading the previous window.
The strange thing is that im not getting any error code in my logcat.
Thank for helping.
This is my code and logcat:
07-12 00:58:51.162: I/ActivityManager(1834): START u0 {cmp=com.tomer.workoutlog/com.example.workoutlog.AddWorkOutPage (has extras)} from pid 28701
07-12 00:58:51.182: D/AudioHardwareMSM7X30(1489): do_aic3254_control device: 1 mode: 0 record: 0
07-12 00:58:51.182: D/AudioHardwareMSM7X30(1489): aic3254_ioctl: new_aic_rxmode 13 cur_aic_rx 29
07-12 00:58:51.182: D/AudioHardwareMSM7X30(1489): aic3254_ioctl()
07-12 00:58:51.182: D/AudioHardwareMSM7X30(1489): aic3254_ioctl: try ioctl 0x40047313 with arg 13
07-12 00:58:51.192: D/AudioHardwareMSM7X30(1489): aic3254_ioctl: new_aic_txmode 29 cur_aic_tx 29
07-12 00:58:51.192: D/AudioHardwareMSM7X30(1489): value of device and enable is 6 1 ALSA dev id:6
07-12 00:58:51.232: D/AudioHardwareMSM7X30(1489): updateACDB: (11, 6, 0, 607)
07-12 00:58:51.232: I/HTC Acoustic(1489): update ACDB id: (tx, rx, tx_acdb, rx_acdb) = (11, 6, 0, 607)
07-12 00:58:51.232: D/AudioHardwareMSM7X30(1489): msm_route_stream(PCM_PLAY,5,6,1)
07-12 00:58:51.652: I/ActivityManager(1834): Displayed com.tomer.workoutlog/com.example.workoutlog.AddWorkOutPage: +474ms
07-12 00:58:52.033: W/InputMethodManagerService(1834): Window already focused, ignoring focus gain of: com.android.internal.view.IInputMethodClient$Stub$Proxy#41948370 attribute=null, token = android.os.BinderProxy#415ff880
code:
class GetKey extends AsyncTask<String, String, String> {
/**
* Before starting background thread Show Progress Dialog
* */
#Override
protected void onPreExecute() {
super.onPreExecute();
pDialog = new ProgressDialog(AddWorkOutPage.this);
pDialog.setMessage("loading...");
pDialog.setIndeterminate(false);
pDialog.setCancelable(true);
pDialog.show();
}
/**
* Creating product
* */
protected String doInBackground(String... args) {
JSONParser jsonParser = new JSONParser();
JSONObject json = null;
// Building Parameters
List<NameValuePair> params = new ArrayList<NameValuePair>();
params.add(new BasicNameValuePair("exercise", exercise));
json = jsonParser.makeHttpRequest(url_get_key,"GET", params);
try {
base64EncodedPublicKey = json.getString("key");
} catch (JSONException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
// check for success tag
try {
int success = json.getInt(TAG_SUCCESS);
if (success == 1) {
// successfully created product
//Log.d("ok", json.toString());
// closing this screen
finish();
} else {
// failed to create product
}
} catch (JSONException e) {
e.printStackTrace();
}
return null;
}
/**
* After completing background task Dismiss the progress dialog
* **/
protected void onPostExecute(String file_url) {
pDialog.dismiss();
}
}
Two potential problems:
As in my comment, you are telling onPostExecute() to accept a String but returning null in doInBackground(). I'm not sure this would cause the problem but I've never tried. If you don't want to return anything you can change to
protected void onPostExecute(Void response)
and change your class declaration to
class GetKey extends AsyncTask<String, Void, Void> {
assuming you are passing a String in execute() when you call the task
2 You are calling finish() in doInBackground() but AsyncTask doesn't have a finish() method so you are either finishing your Activity or getting error there.
The problem is that your calling finish() from your doInBackground() method, so you're modifying in some way your context and getting an exception.
Instead of a String return the Integer from the result and finish() your Activity in the onPostExecute().
class GetKey extends AsyncTask<String, String, Integer> {
/**
* Before starting background thread Show Progress Dialog
* */
#Override
protected void onPreExecute() {
super.onPreExecute();
pDialog = new ProgressDialog(AddWorkOutPage.this);
pDialog.setMessage("loading...");
pDialog.setIndeterminate(false);
pDialog.setCancelable(true);
pDialog.show();
}
/**
* Creating product
* */
protected Integer doInBackground(String... args) {
JSONParser jsonParser = new JSONParser();
JSONObject json = null;
// Building Parameters
List<NameValuePair> params = new ArrayList<NameValuePair>();
params.add(new BasicNameValuePair("exercise", exercise));
json = jsonParser.makeHttpRequest(url_get_key,"GET", params);
try {
base64EncodedPublicKey = json.getString("key");
} catch (JSONException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
// check for success tag
int success = 0;
try {
success = json.getInt(TAG_SUCCESS);
} catch (JSONException e) {
e.printStackTrace();
}
return success;
}
/**
* After completing background task Dismiss the progress dialog
* **/
protected void onPostExecute(Integer success) {
pDialog.dismiss();
if (success == 1) {
// successfully created product
//Log.d("ok", json.toString());
// closing this screen
finish();
} else {
// failed to create product
}
}
}
Related
I am inserting my data in MySql, and the data is inserting successfully. But i am not able to Intent to different Activity after the successful operation.
Here is my code :
public void registerfinish(View view) {
...
new finalRegister().execute();
}
class finalRegister extends AsyncTask<String, String, String> {
/**
* Before starting background thread Show Progress Dialog
* */
#Override
protected void onPreExecute() {
super.onPreExecute();
...
}
/**
* getting All products from url
* */
protected String doInBackground(String... args) {
List<NameValuePair> params = new ArrayList<NameValuePair>();
...
// getting JSON Object
// Note that create product url accepts POST method
JSONObject json = null ;
try {
json = jsonParser.makeHttpRequest(url,
"GET", params);
} catch (JSONException e) {
e.printStackTrace();
}
// check for success tag
try {
// check log cat fro response
Log.d("Create Response", json.toString());
success = json.getInt(TAG_SUCCESS);
} catch (JSONException e) {
e.printStackTrace();
}
if (success == 1) {
// successfully created product
Intent i = new Intent(Register2ndStep.this, FinalScreen.class);
startActivity(i);
// closing this screen
//finish();
} else {
...
}
return null;
}
protected void onPostExecute(String file_url) {
// dismiss the dialog after getting all products
pDialog.dismiss();
}
}
}
Logcat:
Caused by: java.lang.NullPointerException
at wolverine.example.com.btp_scientist.Register2ndStep$finalRegister.doInBackground(Register2ndStep.java:220)
at wolverine.example.com.btp_scientist.Register2ndStep$finalRegister.doInBackground(Register2ndStep.java:173)
Register2ndStep.java:220: Log.d("Create Response", json.toString())
Register2ndStep.java:173: class finalRegister extends AsyncTask<String, String, String>
Just move your intent code to onPostExecute method:
protected void onPostExecute(String file_url) {
Intent i = new Intent(Register2ndStep.this, FinalScreen.class);
startActivity(i);
pDialog.dismiss();
}
I have been using this code for the last few days and up until today it has been working perfectly, but for some reason the Async task has stopped calling the doInBackground method. I have attempted the solution suggested here Android SDK AsyncTask doInBackground not running (subclass) but I just get the same result. The onPreExecute method gets called but then I am just left with the loading dialog. Has anybody experienced anything similar to this. I have included a copy of my code. MyAsncTask is executed as follows;
new MyAsyncTask().execute(email, password);
private class MyAsyncTask extends AsyncTask<String, Void, JSONObject>
{
/**
* Before starting background thread Show Progress Dialog
* */
#Override
protected void onPreExecute() {
Log.v(tag, "onPreExecute");
super.onPreExecute();
pDialog = new ProgressDialog(SignInPageActivity.this);
pDialog.setMessage("Logging in...");
pDialog.setIndeterminate(false);
pDialog.setCancelable(true);
pDialog.show();
}
#Override
protected JSONObject doInBackground(String... params) {
Log.v(tag, "doInBackground");
CustomerFunctions userFunction = new CustomerFunctions();
if (params.length != 2)
return null;
JSONObject json = userFunction.loginUser(params[0], params[1]);
return json;
}
#Override
protected void onPostExecute(JSONObject json)
{
Log.v(tag, "onPostExecute");
try {
if (json != null && json.getString(KEY_SUCCESS) != null) {
signInError.setText("");
String res = json.getString(KEY_SUCCESS);
if(Integer.parseInt(res) == 1){
// user successfully logged in
// Store user details in SQLite Database
DatabaseHandler databaseHandler = new DatabaseHandler(getApplicationContext());
JSONObject json_user = json.getJSONObject("customer");
// Clear all previous data in database
CustomerFunctions userFunction = new CustomerFunctions();
userFunction.logoutCustomer(getApplicationContext());
databaseHandler.addUser(json.getString(KEY_UID), json_user.getString(KEY_FIRST_NAME), json_user.getString(KEY_LAST_NAME), json_user.getString(KEY_EMAIL), json_user.getString(KEY_CURRENT_STAMPS), json_user.getString(KEY_TOTAL_STAMPS), json_user.getString(KEY_REWARDS_AVAILABLE), json_user.getString(KEY_REWARDS_CLAIMED), json_user.getString(KEY_CREATED_AT));
// Launch Dashboard Screen
Intent main = new Intent(getApplicationContext(), MainActivity.class);
// Close all views before launching Dashboard
// dismiss the dialog once done
pDialog.dismiss();
main.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
startActivity(main);
// Close Registration Screen
finish();
}else{
// Error in login
signInError.setText("Incorrect username/password");
}
}
} catch (JSONException e) {
e.printStackTrace();
}
}
try extending like this
private class MyAsyncTask<Params, Void, JSONObject> extends AsyncTask<Params, Void, JSONObject>
and use #Override for doInBackground
Hello android developers! I have one problem with compatibility of my old codes and API 18.
All codes bellow runs perfectly in android 2.3. But when I try to run it on a newer API it crashes. Can I use it without runOnUiThread for updating my UI? What I shoud change? Thanks!
class GetDetails extends AsyncTask<String, String, String> {
#Override
protected void onPreExecute() {
super.onPreExecute();
pDialog = new ProgressDialog(QueryProduct.this);
pDialog.setMessage("Loading product details. Please wait...");
pDialog.setIndeterminate(false);
pDialog.setCancelable(true);
pDialog.show();
}
protected String doInBackground(String... params) {
// updating UI from Background Thread
runOnUiThread(new Runnable() {
public void run() {
int success;
try {
List<NameValuePair> params = new ArrayList<NameValuePair>();
params.add(new BasicNameValuePair("id", id));
JSONObject json = jsonParser.makeHttpRequest(
url_product_detials, "GET", params);
success = json.getInt(TAG_SUCCESS);
if (success == 1) {
JSONArray productObj = json
.getJSONArray(TAG_PRODUCT);
JSONObject product = productObj.getJSONObject(0);
tvName = (TextView) findViewById(R.id.tvName);
tvName.setText(product.getString(TAG_NAME));
}else{
}
} catch (JSONException e) {
e.printStackTrace();
}
}
});
return null;
}
protected void onPostExecute(String file_url) {
pDialog.dismiss();
}
}
Can I use it without runOnUiThread for updating my UI?
YES! Please do! Remove runOnUiThread() and return your result to onPostExecute() and update UI there. That's why the other methods exist.
The way you have it, you are running all of your background stuff on the UI which defeats the purpose of AsyncTask.
You can simply change your class definition to pass the int to onPostExecute()
class GetDetails extends AsyncTask<String, String, Integer>
then return success in doInBackground(). And check that value in onPostExecute() and update UI if success.
protected void onPostExecute(Integer result)
{
if (result == 1)
{
// code to update UI
Further ExplanationBe sure to read through the AsyncTask Docs really well. This class was created so that you can do your heavy-lifting such as network stuff on a background Thread (doInBackground()) and update the UI in it's built-in methods (the other 3).
onPreExecute() can update before the task starts such as for a
ProgressDialg
onProgressUpdate() can update while doInBackground() is still processing such as for the progress of a downloading file by calling publishProgress()
onPostExecute() is called when doInBackground() finishes to
update anything you need when the task finishes such as dismissing a
ProgressDialog
class GetDetails extends AsyncTask<String, String, String> {
#Override
protected void onPreExecute() {
super.onPreExecute();
pDialog = new ProgressDialog(QueryProduct.this);
pDialog.setMessage("Loading product details. Please wait...");
pDialog.setIndeterminate(false);
pDialog.setCancelable(true);
pDialog.show();
}
// Do your Background Task Inside it and inside it when you want to update the Ui
// then call the method publishProgress. this call the method onProgressUpdate that
// run on the UI thread and inside it you update your UI
protected String doInBackground(String... params) {
int success;
try {
List<NameValuePair> params = new ArrayList<NameValuePair>();
params.add(new BasicNameValuePair("id", id));
JSONObject json = jsonParser.makeHttpRequest(
url_product_detials, "GET", params);
success = json.getInt(TAG_SUCCESS);
if (success == 1) {
JSONArray productObj = json
.getJSONArray(TAG_PRODUCT);
JSONObject product = productObj.getJSONObject(0);
String result = product.getString(tvName)
// Need To Update the Ui so call the method publishProgress(result );
// this will call onProgressUpdate(String... values) method and
// String result i provide it to so that i can update the text view
// in it.
//Update in publish progress you can specify multiple String values
// and same received in onProgressUpdate as an array of values.
//publishProgress("value1","value2","value3")
publishProgress(result,"result2","result3");
}else{
}
} catch (JSONException e) {
e.printStackTrace();
}
return null;
}
// run on the Ui thread so inside it you can update your UI
protected void onProgressUpdate(String... values)
{
super.onProgressUpdate(values);
tvName = (TextView) findViewById(R.id.tvName);
tvName.setText(values[0]);
tvPrice = (TextView) findViewById(R.id.tvPrice);
tvPrice.setText(values[1]);
tvAdress = (TextView) findViewById(R.id.tvAdress);
tvAdress .setText(values[2]);
}
protected void onPostExecute(String file_url) {
pDialog.dismiss();
}
}
I need some help with taking results from doinbackground to onpostexecute. The results are in the form of JSONArray. I want to populate two textviews in the UI through onpostexecute. There is no error in the code but nothing happens as it seems inpostexecute is not getting called. Please help. I have looked at several similar questions here and tried many things but unable to get it to work..thanks in advance. Please note private static final String TAG_LATEST_SCORES = "cricket_scores";
class PostScores extends AsyncTask<JSONArray, Void, JSONArray> {
/**
* Before starting background thread Show Progress Dialog
* */
#Override
protected void onPreExecute() {
super.onPreExecute();
pDialog = new ProgressDialog(NewScoreupdatescricketActivity.this);
pDialog.setMessage("Posting LiveScore Updates..");
pDialog.setIndeterminate(false);
pDialog.setCancelable(true);
pDialog.show();
}
/**
* Creating product
* */
protected JSONArray doInBackground(JSONArray... args) {
String runs1 = runs.getText().toString();
String wicket1 = wicket.getText().toString();
String overs1 = over.getText().toString();
String rr1 = rr.getText().toString();
String team_name = null;
String bat1;
if (innings.isChecked() == false) {
bat1 = "1";
team_name = bat.getText().toString();
} else {
bat1 = "2";
team_name = bat.getText().toString();
}
if (rr1.equals("NA")) {
rr1 = "0";
}
// Building Parameters
List<NameValuePair> params = new ArrayList<NameValuePair>();
params.add(new BasicNameValuePair("runs", runs1));
params.add(new BasicNameValuePair("wickets", wicket1));
params.add(new BasicNameValuePair("id", id1));
params.add(new BasicNameValuePair("overs", overs1));
params.add(new BasicNameValuePair("rr", rr1));
params.add(new BasicNameValuePair("bat", bat1));
params.add(new BasicNameValuePair("team_name", team_name));
// getting JSON Object
// Note that create product url accepts POST method
JSONObject json = jsonParser.makeHttpRequest(url_create_product,
"POST", params);
// check log cat fro response
Log.d("Create Response", json.toString());
// check for success tag
try {
int success = json.getInt(TAG_SUCCESS);
pDialog.dismiss();
if (success == 1) {
latest_scores = json.getJSONArray(TAG_LATEST_SCORES);
} else {
}
} catch (JSONException e) {
e.printStackTrace();
}
pDialog.dismiss();
return latest_scores;
}
}
/**
* After completing background task Dismiss the progress dialog
* **/
protected void onPostExecute(JSONArray latest_sc) {
// dismiss the dialog once done
try {
for (int i = 0; i < latest_sc.length(); i++) {
JSONObject c = latest_sc.getJSONObject(i);
String wickets = c.getString(TAG_WICKETS);
String runs = c.getString(TAG_RUNS);
score_inngs1.setText(wickets + runs);
}
} catch (JSONException e) {
e.printStackTrace();
}
}
}
Check your brackets. After your definition of doInBackground, you have an extra bracket - that one closes off your PostScores class, so your onPostExecute method is defined as a member of whatever class is enclosing PostScores, if any.
Also, you'll need to #Override the AsyncTask methods to provide your own implementation.
after the crashing problem been solved now the application is not executing the update or deleting
when i update it crashes immediately but when i delete it shows me the toast and nothing happens then
this is the class
public class EditCard extends Activity {
EditText txtName;
EditText txtPosition;
EditText txtCollege;
EditText txtPhone;
Button btnSave;
Button btnDelete;
String cid;
// Progress Dialog
private ProgressDialog pDialog;
// JSON parser class
JSONParser jsonParser = new JSONParser();
// single product url
private static final String url_card_details = "http://XXX";
// url to update product
private static final String url_update_card = "http://XXX";
// url to delete product
private static final String url_delete_card = "http://XXX";
// JSON Node names
private static final String TAG_SUCCESS = "success";
private static final String TAG_CARDS = "cards";
private static final String TAG_CID = "cid";
private static final String TAG_CNAME = "name";
private static final String TAG_POSITION = "position";
private static final String TAG_COLLEGE = "college";
private static final String TAG_PHONE = "phone";
#Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.edit_card);
StrictMode.ThreadPolicy policy = new StrictMode.ThreadPolicy.Builder()
.permitAll().build();
StrictMode.setThreadPolicy(policy);
// save button
btnSave = (Button) findViewById(R.id.SaveCard);
btnDelete = (Button) findViewById(R.id.DeleteCard);
// getting product details from intent
Intent i = getIntent();
// getting product id (pid) from intent
cid = i.getStringExtra(TAG_CID);
// Getting complete product details in background thread
new GetCardDetails().execute();
// save button click event
btnSave.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View arg0) {
// starting background task to update product
new SaveCardDetails().execute();
}
});
// Delete button click event
btnDelete.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View arg0) {
// deleting product in background thread
new DeleteCard().execute();
}
});
}
/**
* Background Async Task to Get complete product details
* */
class GetCardDetails extends AsyncTask<String, String, String> {
/**
* Before starting background thread Show Progress Dialog
* */
#Override
protected void onPreExecute() {
super.onPreExecute();
pDialog = new ProgressDialog(EditCard.this);
pDialog.setMessage("Loading card details. Please wait...");
pDialog.setIndeterminate(false);
pDialog.setCancelable(true);
pDialog.show();
}
/**
* Getting product details in background thread
* */
protected String doInBackground(String... params) {
// updating UI from Background Thread
runOnUiThread(new Runnable() {
public void run() {
// Check for success tag
int success;
try {
// Building Parameters
List<NameValuePair> params = new ArrayList<NameValuePair>();
params.add(new BasicNameValuePair("cid", cid));
// getting product details by making HTTP request
// Note that product details url will use GET request
JSONObject json = jsonParser.makeHttpRequest(
url_card_details, "GET", params);
// check your log for json response
Log.d("Single Product Details", json.toString());
// json success tag
success = json.getInt(TAG_SUCCESS);
if (success == 1) {
// successfully received product details
JSONArray cardObj = json
.getJSONArray(TAG_CARDS); // JSON Array
// get first product object from JSON Array
JSONObject card = cardObj.getJSONObject(0);
// product with this pid found
// Edit Text
txtName = (EditText) findViewById(R.id.editCard1);
txtPosition = (EditText) findViewById(R.id.editCard2);
txtCollege= (EditText) findViewById(R.id.editCard3);
txtPhone= (EditText) findViewById(R.id.editCard4);
// display product data in EditText
txtName.setText(card.getString(TAG_CNAME));
txtPosition.setText(card.getString(TAG_POSITION));
txtCollege.setText(card.getString(TAG_COLLEGE));
txtPhone.setText(card.getString(TAG_PHONE));
}else{
// product with pid not found
}
} catch (JSONException e) {
e.printStackTrace();
}
}
});
return null;
}
/**
* After completing background task Dismiss the progress dialog
* **/
protected void onPostExecute(String file_url) {
// dismiss the dialog once got all details
pDialog.dismiss();
}
}
/**
* Background Async Task to Save product Details
* */
class SaveCardDetails extends AsyncTask<String, String, String> {
/**
* Before starting background thread Show Progress Dialog
* */
#Override
protected void onPreExecute() {
super.onPreExecute();
pDialog = new ProgressDialog(EditCard.this);
pDialog.setMessage("Saving Card ...");
pDialog.setIndeterminate(false);
pDialog.setCancelable(true);
pDialog.show();
}
/**
* Saving product
* */
protected String doInBackground(String... args) {
// getting updated data from EditTexts
String name = txtName.getText().toString();
String position = txtPosition.getText().toString();
String college = txtCollege.getText().toString();
String phone = txtPhone.getText().toString();
// Building Parameters
List<NameValuePair> params = new ArrayList<NameValuePair>();
params.add(new BasicNameValuePair("name", name));
params.add(new BasicNameValuePair("position", position));
params.add(new BasicNameValuePair("college", college));
params.add(new BasicNameValuePair("phone", phone));
// sending modified data through http request
// Notice that update product url accepts POST method
JSONObject json = jsonParser.makeHttpRequest(url_update_card,
"POST", params);
// check json success tag
try {
int success = json.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();
}
return null;
}
/**
* After completing background task Dismiss the progress dialog
* **/
protected void onPostExecute(String file_url) {
// dismiss the dialog once product uupdated
Toast.makeText(getApplicationContext(), "The Student Card Updated sucessfully", Toast.LENGTH_LONG).show();
pDialog.dismiss();
}
}
/*****************************************************************
* Background Async Task to Delete Product
* */
class DeleteCard extends AsyncTask<String, String, String> {
/**
* Before starting background thread Show Progress Dialog
* */
#Override
protected void onPreExecute() {
super.onPreExecute();
pDialog = new ProgressDialog(EditCard.this);
pDialog.setMessage("Deleting Card...");
pDialog.setIndeterminate(false);
pDialog.setCancelable(true);
pDialog.show();
}
/**
* Deleting product
* */
protected String doInBackground(String... args) {
// Check for success tag
int success;
try {
// Building Parameters
List<NameValuePair> params = new ArrayList<NameValuePair>();
params.add(new BasicNameValuePair("cid", cid));
// getting product details by making HTTP request
JSONObject json = jsonParser.makeHttpRequest(
url_delete_card, "POST", params);
// check your log for json response
Log.d("Delete Card", json.toString());
// json success tag
success = json.getInt(TAG_SUCCESS);
if (success == 1) {
// product successfully deleted
// notify previous activity by sending code 100
Intent i = getIntent();
// send result code 100 to notify about product deletion
setResult(100, i);
finish();
}
} catch (JSONException e) {
e.printStackTrace();
}
return null;
}
/**
* After completing background task Dismiss the progress dialog
* **/
protected void onPostExecute(String file_url) {
// dismiss the dialog once product deleted
Toast.makeText(getApplicationContext(), "The Student Card deleted sucessfully", Toast.LENGTH_LONG).show();
pDialog.dismiss();
}
}
}
and this is the LogCat when i update
07-18 01:15:53.053: W/dalvikvm(8740): threadid=11: thread exiting with uncaught exception (group=0x40a71930)
07-18 01:15:53.383: E/AndroidRuntime(8740): FATAL EXCEPTION: AsyncTask #1
07-18 01:15:53.383: E/AndroidRuntime(8740): java.lang.RuntimeException: An error occured while executing doInBackground()
07-18 01:15:53.383: E/AndroidRuntime(8740): at android.os.AsyncTask$3.done(AsyncTask.java:299)
07-18 01:15:53.383: E/AndroidRuntime(8740): at java.util.concurrent.FutureTask.finishCompletion(FutureTask.java:352)
07-18 01:15:53.383: E/AndroidRuntime(8740): at java.util.concurrent.FutureTask.setException(FutureTask.java:219)
07-18 01:15:53.383: E/AndroidRuntime(8740): at java.util.concurrent.FutureTask.run(FutureTask.java:239)
07-18 01:15:53.383: E/AndroidRuntime(8740): at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:230)
07-18 01:15:53.383: E/AndroidRuntime(8740): at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1080)
07-18 01:15:53.383: E/AndroidRuntime(8740): at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:573)
07-18 01:15:53.383: E/AndroidRuntime(8740): at java.lang.Thread.run(Thread.java:856)
07-18 01:15:53.383: E/AndroidRuntime(8740): Caused by: java.lang.NullPointerException
07-18 01:15:53.383: E/AndroidRuntime(8740): at com.example.ahliaevents.EditCard$SaveCardDetails.doInBackground(EditCard.java:210)
07-18 01:15:53.383: E/AndroidRuntime(8740): at com.example.ahliaevents.EditCard$SaveCardDetails.doInBackground(EditCard.java:1)
07-18 01:15:53.383: E/AndroidRuntime(8740): at android.os.AsyncTask$2.call(AsyncTask.java:287)
07-18 01:15:53.383: E/AndroidRuntime(8740): at java.util.concurrent.FutureTask.run(FutureTask.java:234)
07-18 01:15:53.383: E/AndroidRuntime(8740): ... 4 more
and this is the LogCat when i delete
07-18 01:18:01.584: E/JSON Parser(8850): Error parsing data org.json.JSONException: Value <!DOCTYPE of type java.lang.String cannot be converted to JSONObject
For your delete crash, you're not getting JSON back from the server, you're probably getting an error page. The parser is expecting to see JSON and it sees what appears to be the beginning of an XML/XHTML document.
For your other crash, just look at your source at line 210. You're getting a NullPointerException, which means that you expect something to be an object, but it's a null reference.
Most alarming is your use of runOnUiThread() within a doInBackground() the whole point of doInBackground is to avoid the UI Thread.