public void OnBtnSendClick(View v)
{
byte[] bytes = ...; // array is assigned here
SendTask task = new SendTask();
task.execute(new byte[][] {bytes}); // this line is executed
}
private class SendTask extends AsyncTask<byte[], Void, String>
{
@Override
protected String doInBackground(byte[]... parameters)
{
Log.i(LOG_TAG, "SendTask.doInBackground started"); // this line is not executed
return "OK";
}
@Override
protected void onPostExecute(String result)
{
// ...
}
}
This code worked with android:targetSdkVersion="9" in the manifest. I changed it to android:targetSdkVersion="15", and now SendTask.doInBackground is not executed. In debugger I see that task.execute line is executed, but doInBackground is never called.
BTW, the program contains another AsyncTask, which is successfully running.
http://developer.android.com/reference/android/os/AsyncTask.html
On API >= 11 by default only one
AsyncTaskis executed at a time.One way to overcome this issue is to create a
BaseTaskand make all your tasks extends itThen when you need to execute it, simply call
myTask.fireInTheHole()instead ofmyTask.execute()