Answer the question
In order to leave comments, you need to log in
Why does the application crash after calling AsyncTask?
I'm just confused. I have a main activity and there are asynctasks and they all work great. I created another activity and I’m doing functionality there, and I needed an ajunktask, I wrote a simple one:
private class sendMsg extends AsyncTask<Void, Void, Void> {
@Override
protected Void doInBackground(Void... params) {
Toast.makeText(getApplicationContext(),"Тест тест",Toast.LENGTH_SHORT).show();
return null;
}
@Override
protected void onPostExecute(Void result) {
super.onPostExecute(result);
}
}
public void UploadBmp (View view){
new GetTokenOTOP().execute();
}
FATAL EXCEPTION: AsyncTask #1
E/AndroidRuntime: Process: Sergey.CamEdit, PID: 6989
E/AndroidRuntime: java.lang.RuntimeException: An error occured while executing doInBackground()
Answer the question
In order to leave comments, you need to log in
you are accessing the ui thread in doInBackground, replace toast with Log.d
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question