I have an AsyncTask which retrieves data from a server and then needs to start a new Activity to display the data.
doing this within the ASync onPostExecute works… (but doesn’t start the new activity)
setContentView(R.layout.activity_list);
TextView textListDate = ((TextView)findViewById(R.id.textListDate));
textListDate.setText(FormatUtilities.formatDateLong(list.getDateFor()));
doing this results in a null pointer exception (due to TextListDate being null
Intent in = new Intent(super.getAppContext(), List.class);
in.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
super.getAppContext().startActivity(in);
TextView textListDate = ((TextView)findViewById(R.id.textListDate));
textListDate.setText(FormatUtilities.formatDateLong(list.getDateFor()));
and doing this results in a screen loading with what i want, and then being blanked almost immediatley…
Intent in = new Intent(super.getAppContext(), List.class);
in.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
super.getAppContext().startActivity(in);
setContentView(R.layout.activity_list);
TextView textListDate = ((TextView)findViewById(R.id.textListDate));
textListDate.setText(FormatUtilities.formatDateLong(list.getDateFor()));
any suggestions on what I am missing? I assume it is something to do with findViewById trying to access the view of the “current” activity and not the new one…
Do i somehow need to pass my data to the new Activity and do the findViewById inside the next activity?
thanks for the help.
1)- You should save your data in ArrayList or according to the response from server, And put that data with key,value pair with intent , and then retrieve that intent in next Activity.
2)- Now you can display that data in desired place i.e. Listview,Text view etc.
thanks