This is My Activity(pActivity5)-
BackgroundWorker backgroundWorker=new BackgroundWorker(pActivity5.this,this);
backgroundWorker.execute(type,str1);
arrayList1.clear();
arrayList2.clear();
sharedPreferences=getSharedPreferences("p_name_tech_1",MODE_PRIVATE);
int a=sharedPreferences.getInt("s_o_a",0);
for(int i=0;i<a;i++){
arrayList1.add(i,sharedPreferences.getString(""+i,"null"));
}
for(int i=a;i<(a*2);i++){
arrayList2.add((i-a),sharedPreferences.getString(""+i,"null"));
}
adapter=new Adapter(this,arrayList1,arrayList2);
adapter.notifyDataSetChanged();
lv1.setAdapter(adapter);
This is my onPostExecute method in BackgroundWorker Class-
intent = new Intent(context, pActivity5.class);
intent.setFlags(Intent.FLAG_ACTIVITY_NO_HISTORY);
intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
context.startActivity(intent);
When I use backgroundWorker.execute(type,str1).get(); then it works fine but that Defeats the purpose of AsyncTask. So I want to use AsyncTask and update my ListView on its completion.
I have even tried this- How to get the result of OnPostExecute() to main activity because AsyncTask is a separate class? but no success.