Try using an event bus library such as greenrobot EventBus. The process will be performed in 4 lines of code:
(In the work of the sender)
EventBus.getDefault().register(this); EventBus.getDeafult().postSticky(myDataObject);
(Upon receipt of activity)
DataObject passedData = EventBus.getDefault().getStickyEvent(DataObject.class);
You will also need a POJO data class:
public static class DataObject{ private String data; public String getData(){ return data; } public void setData(String data){ this.data = data; } }
Clean, fast and elegant :-)
Kelevandos
source share