I have a splash screen activity(ACTIVITY A) which on load completion opens ACTIVITY B
ACTIVITY B ** consists of a button which opens **ACTIVITY C
ACTIVITY A loads a list using async task
I want this loaded list to be displayed in ACTIVITY C when opened
I have read many posts on how to pass values from 1st activity to 3rd activity and tried implementing all those but nothing helped
Evven tried passing the list object via intents from ACTIVITY A > ACTÌVITY B > ACTIVITY C but didnt work
Finally i have used " jacksons library " to convert the loaded list into a jsonstring then put it in sharedpreferences in ACTIVITY A , then retrive the jsonstring from sharedpreferences covert it back to list object in ** ACTIVITY C** and display the list
But the list is not getting displayed
What to do and is there any better process
splash activity(ACTIVITY A)
public class SplashActivity extends Activity{
List<ParseObject> ob;
List<CodeList> codelist = null;
ObjectMapper mapper;
SearchPreferences searchpref;
@Override
public void onCreate(Bundle savedInstanceState){
// TODO: Implement this method
super.onCreate(savedInstanceState);
setContentView(R.layout.splash);
mapper = new ObjectMapper();
searchpref = new SearchPreferences();
new DataTask().execute();
}
public class DataTask extends AsyncTask<Void, Void, List<CodeList>>{
@Override
protected List<CodeList> doInBackground(Void[] p1){
codelist = new ArrayList<CodeList>();
try {
ParseQuery<ParseObject> query = new ParseQuery<ParseObject>("InterActivity");
query.orderByAscending("_created_at");
ob = query.find();
for (ParseObject inter : ob) {
CodeList map = new CodeList();
map.setIntroduction((String) inter.get("intro"));
codelist.add(map);
}
return codelist;
}
catch (ParseException e) {
Log.e("Error", e.getMessage());
e.printStackTrace();
}
return null;
}
@Override
protected void onPostExecute(List<CodeList> result){
try{
String jsonsearchlist = mapper.writeValueAsString(result);
Intent i = new Intent(SplashActivity.this, MainActivity.class);
searchpref.save(SplashActivity.this, jsonsearchlist);
startActivity(i);
}
catch (JsonProcessingException e){}
}
}
}
ACTIVITY C
public class SearchActivity extends Activity{
protected EditText searchedittext;
ImageButton searchButton;
List<ParseObject> ob;
List<CodeList> splashcodes;
FinalAdapter fnladapter;
SearchPreferences searchpref;
ObjectMapper mapper;
@Override
public void onCreate(Bundle savedInstanceState){
super.onCreate(savedInstanceState);
setContentView(R.layout.search_layout);
searchpref = new SearchPreferences();
mapper = new ObjectMapper();
String jsonsearchobj = searchpref.getValue(SearchActivity.this);
try{
splashcodes = (List<CodeList>) mapper.readValue(jsonsearchobj, CodeList.class);
final ListView searchedlist = (ListView) findViewById(R.id.searchlist);
fnladapter = new FinalAdapter(SearchActivity.this, splashcodes);
searchedlist.setAdapter(fnladapter);
}
catch (IOException e){}
}
}