Click here to Skip to main content
15,899,632 members
Home / Discussions / Android
   

Android

 
QuestionRooting on all android device Pin
sanjeev badoni1-Mar-14 3:22
sanjeev badoni1-Mar-14 3:22 
QuestionAndroid Programming JSONParsing Error Pin
Cyber1226-Feb-14 2:00
Cyber1226-Feb-14 2:00 
Questiontakes too long to run android simulator, looking for alternatives. Pin
ankum1623-Feb-14 18:33
ankum1623-Feb-14 18:33 
AnswerRe: takes too long to run android simulator, looking for alternatives. Pin
Naveenvenk25-Feb-14 7:07
Naveenvenk25-Feb-14 7:07 
AnswerRe: takes too long to run android simulator, looking for alternatives. Pin
Kornfeld Eliyahu Peter26-Feb-14 5:29
professionalKornfeld Eliyahu Peter26-Feb-14 5:29 
AnswerRe: takes too long to run android simulator, looking for alternatives. Pin
Peter Leow1-Mar-14 3:34
professionalPeter Leow1-Mar-14 3:34 
AnswerRe: takes too long to run android simulator, looking for alternatives. Pin
Member 105770039-Mar-14 8:15
Member 105770039-Mar-14 8:15 
QuestionAndroid AsynkTask Taking too Long Rotating Progress Dialog Pin
Cyber1221-Feb-14 21:38
Cyber1221-Feb-14 21:38 
AsyncTask takes too long to do tasks while rotating Progress Dialog, finally the application crashes displaying the message "Unfortunately "App_Name" has stopped."

What should I do in onPreExecute, doInbackground, onPostExecute so as to solve this problem?
What are the most likely causes this?

PLEASE TELL ME IF THIS IS THE STANDARD CODE FOR AsynkTask!!!

THANK YOU IN ADVANCE FOR YOUR TIME!!!

The AsynkTask Code I used is below:

package com.Project.mbjs;

import java.util.ArrayList;
import java.util.List;

import org.apache.http.NameValuePair;
import org.apache.http.message.BasicNameValuePair;
import org.json.JSONException;
import org.json.JSONObject;

import android.app.Activity;
import android.app.ProgressDialog;
import android.content.Intent;
import android.os.AsyncTask;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.Toast;
import android.os.Bundle;
import android.app.Activity;
import android.view.Menu;

public class RegisterJobSeeker extends Activity {

// Progress Dialog
private ProgressDialog pDialog;
JSONParser jsonParser = new JSONParser();
EditText inputFirstName;
EditText inputLastName;
EditText inputEmail;
EditText inputPassword;
EditText inputExperience;
EditText inputEduLevel;
EditText inputPhoneNo;

// URL to register Job Seeker
private static String URL_RegisterJobSeeker = "http://10.0.2.2 /mbjs/RegisterJobSeeker.php";

// JSON Node names
private static final String TAG_SUCCESS = "success";

<a href="/Members/override">@Override</a>
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.registerjobseeker);

// Edit Text
inputFirstName = (EditText) findViewById(R.id.txtFName);
inputLastName = (EditText) findViewById(R.id.txtLName);
inputEmail = (EditText) findViewById(R.id.txtEmail);
inputPassword = (EditText) findViewById(R.id.txtPassword);
inputExperience = (EditText) findViewById(R.id.txtExperience);
inputEduLevel = (EditText) findViewById(R.id.txtEduLevel);
inputPhoneNo = (EditText) findViewById(R.id.txtPhoneNo);

// Create button
Button btnRegister = (Button) findViewById(R.id.btnRegister);
// button click event
btnRegister.setOnClickListener(new View.OnClickListener() {

<a href="/Members/override">@Override</a>
public void onClick(View view) {
// creating new product in background thread
new AddJobSeeker().execute();
}
});
}

/** * Background Async Task to Create new product * */
class AddJobSeeker extends AsyncTask<String, String, String> {
/** * Before starting background thread Show Progress Dialog * */
<a href="/Members/override">@Override</a>
protected void onPreExecute() {
super.onPreExecute();
pDialog = new ProgressDialog(RegisterJobSeeker.this);
pDialog.setMessage("Registering Job Seeker...");
pDialog.setIndeterminate(false);
pDialog.setCancelable(true);
pDialog.show();
}

<a href="/Members/override">@Override</a>
protected String doInBackground(String... args) {
String firstName = inputFirstName.getText().toString();
String lastName = inputLastName.getText().toString();
String email = inputEmail.getText().toString();
String password = inputPassword.getText().toString();
String experience = inputExperience.getText().toString();
String eduLevel = inputEduLevel.getText().toString();
String phoneNo = inputPhoneNo.getText().toString();

// Building Parameters
List<NameValuePair> params = new ArrayList<NameValuePair>();
params.add(new BasicNameValuePair("firstName", firstName));
params.add(new BasicNameValuePair("lastName", lastName));
params.add(new BasicNameValuePair("email", email));
params.add(new BasicNameValuePair("password", password));
params.add(new BasicNameValuePair("experience", experience));
params.add(new BasicNameValuePair("eduLevel", eduLevel));
params.add(new BasicNameValuePair("phoneNo", phoneNo));
// getting JSON Object
// Note that create product url accepts POST method
JSONObject json = jsonParser.makeHttpRequest(URL_RegisterJobSeeker,
"POST", params);
// check log cat for response
Log.d("Create Response", json.toString());
// check for success tag
try {
int success = json.getInt(TAG_SUCCESS);
if (success == 1) {
// successfully created product

Toast.makeText(RegisterJobSeeker.this,
"Job Seeker Successfully Registered.",
Toast.LENGTH_LONG).show();;
// Intent i = new
// Intent(getApplicationContext(),RegisterJobSeeker.class);
// startActivity(i);
// 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) {
// dismiss the dialog once done
pDialog.dismiss();
}
}
}

-- modified 25-Feb-14 2:57am.
AnswerRe: Android AsynkTask Taking too Long to respond Pin
Cyber1221-Feb-14 23:13
Cyber1221-Feb-14 23:13 
AnswerRe: Android AsynkTask Taking too Long Rotating Progress Dialog Pin
BupeChombaDerrick9-Mar-14 1:01
BupeChombaDerrick9-Mar-14 1:01 
QuestionAndroid Sync Adapter Xamarin Pin
Naga Suresh18-Feb-14 1:13
Naga Suresh18-Feb-14 1:13 
AnswerRe: Android Sync Adapter Xamarin Pin
Ahmed Bensaid26-Feb-14 2:17
professionalAhmed Bensaid26-Feb-14 2:17 
AnswerRe: Call blocking Pin
Peter Leow16-Feb-14 13:26
professionalPeter Leow16-Feb-14 13:26 
SuggestionRe: Call blocking Pin
Richard MacCutchan16-Feb-14 22:58
mveRichard MacCutchan16-Feb-14 22:58 
GeneralRe: Call blocking Pin
Tom Marvolo Riddle16-Feb-14 23:19
professionalTom Marvolo Riddle16-Feb-14 23:19 
QuestionRe: Call blocking Pin
thatraja16-Feb-14 23:40
professionalthatraja16-Feb-14 23:40 
AnswerRe: Call blocking Pin
Richard MacCutchan17-Feb-14 0:37
mveRichard MacCutchan17-Feb-14 0:37 
GeneralRe: Call blocking Pin
Richard Deeming17-Feb-14 2:09
mveRichard Deeming17-Feb-14 2:09 
GeneralRe: Call blocking Pin
Richard MacCutchan17-Feb-14 2:32
mveRichard MacCutchan17-Feb-14 2:32 
QuestionWhich environment... Pin
Kornfeld Eliyahu Peter12-Feb-14 10:47
professionalKornfeld Eliyahu Peter12-Feb-14 10:47 
AnswerRe: Which environment... Pin
Jubayer Ahmed12-Feb-14 18:01
professionalJubayer Ahmed12-Feb-14 18:01 
AnswerRe: Which environment... Pin
Ahmed Bensaid13-Feb-14 2:44
professionalAhmed Bensaid13-Feb-14 2:44 
AnswerRe: Which environment... Pin
thatraja13-Feb-14 3:32
professionalthatraja13-Feb-14 3:32 
AnswerRe: Which environment... Pin
ManvendraKumarSah14-Feb-14 2:24
ManvendraKumarSah14-Feb-14 2:24 
AnswerRe: Which environment... Pin
Member 1058259714-Feb-14 6:48
Member 1058259714-Feb-14 6:48 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.