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:
- if data needs synced once details shown - add logic
ticketdetailactivity
inoncreate()
(the simplest approach useasynctask
) - if want implement sync button in
saveticketdetailactivity
, sync data when button pressed - bad user experience. better design have button inticketdetailactivity
.
said that, if still want share small amount of data between multiple activities, best option use sharedpreferences
. see this question short tutorial.
Comments
Post a Comment