Android app crashes on Async Task
Posted
by
Telmo Vaz
on Stack Overflow
See other posts from Stack Overflow
or by Telmo Vaz
Published on 2013-11-13T15:49:28Z
Indexed on
2013/11/13
15:52 UTC
Read the original article
Hit count: 179
why is my APP crashing when I invoke the AsyncTask?
public class Login extends Activity {
String mail;
EditText mailIn;
Button btSubmit;
@Override
protected void onCreate(Bundle tokenArg) {
super.onCreate(tokenArg);
setContentView(R.layout.login);
mailIn = (EditText)findViewById(R.id.usermail);
btSubmit = (Button)findViewById(R.id.submit);
btSubmit.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View thisView) {
new LoginProc().execute();
}
});
}
public class LoginProc extends AsyncTask<String, Void, Void> {
@Override
protected void onPreExecute() {
mailIn = (EditText)findViewById(R.id.usermail);
mail = mailIn.getText().toString();
super.onPreExecute();
}
@Override
protected Void doInBackground(String... params) {
Toast.makeText(getApplicationContext(), mail, Toast.LENGTH_SHORT).show();
return null;
}
}
}
I'm trying to make the String name get it's value on the preExecute method, but it happens that the app crashes on that point. Even if I take the preExecute and do that on the doInBrackground, it still crashes. What's wrong?
© Stack Overflow or respective owner