java - How to pass same String value from adapter to two different activities -


i have ticketadapter class in onclick method i'm passing string value (i.e ticket.getid()) ticket pojo class) ticketdetailactivity class, want pass same value 1 more activity i.e saveticketdetailactivity class

public class ticketadapter extends baseadapter { protected list<ticket> tickets;  public void onclick(view v) {     activity activity = getactivity();     intent intent = new intent(getactivity(), ticketdetailactivity.class);     intent.putextra("com.qurater.csr.ticket.id", ticket.getid());     getactivity().startactivity(intent);     activity.overridependingtransition(r.anim.slide_left_detail, r.anim.stay_in_place_detail); } 

here click when intent fired i'm getting value (i.e ticket.getid())in ticketdetailactivity class.

now want same value reference in saveticketdetailactivity.class want value i'm sending string data server url needs id , data.

i can hardly imagine scenario when data needs passed 2 activities in parallel. maybe can pass data ticketdetailactivity , there pass saveticketdetailactivity if needed? furthermore, using entirely new activity purpose of sending data server seems overkill. got 2 better options:

  1. if data needs synced once details shown - add logic ticketdetailactivity in oncreate() (the simplest approach use asynctask)
  2. if want implement sync button in saveticketdetailactivity , sync data when button pressed - bad user experience. better design have button in ticketdetailactivity.

said that, if still want share small amount of data between multiple activities, best option use sharedpreferences. see this question short tutorial.


Comments

Popular posts from this blog

javascript - gulp-nodemon - nodejs restart after file change - Error: listen EADDRINUSE events.js:85 -

Fatal Python error: Py_Initialize: unable to load the file system codec. ImportError: No module named 'encodings' -

javascript - oscilloscope of speaker input stops rendering after a few seconds -