The field temp
is null when you pass it in in createDynamicTable(temp)
, and this blows up in the body of the method when you access tableContentList.length
. The fact is, AsyncTask
spawns another thread in the background that executes doInBackground()
. Here you initialise the field temp
but you cannot count on this happening before createDynamicTable(temp)
.
Try calling createDynamicTable(temp)
in onPostExecute()
and remove line 85
@Override
protected void onPostExecute(String[] temp) {
dialog.dismiss();
DutyRoster.this.temp = temp;
createDynamicTable(temp);
}
By the way, watch out the leaks!