how to send message between activities in android -
my app works follow: user hits compose button , types message sends main activity date , time in recycler view swipe refresh facebook or other type of social media. problem i'm having i'm new android development , haven't seen on google site.
you have 2 options:
- send data in intent:
use "put" file...
intent = new intent(firstscreen.this, secondscreen.class); string keyidentifer = null; i.putextra("string_i_need", strname);
then, retrieve value try like:
string newstring; if (savedinstancestate == null) { bundle extras = getintent().getextras(); if(extras == null) { newstring= null; } else { newstring= extras.getstring("string_i_need"); } } else { newstring= (string) savedinstancestate.getserializable("string_i_need"); }
- use event bus register , handle events more advanced data , callbacks: example of use https://github.com/greenrobot/eventbus/blob/master/howto.md
Comments
Post a Comment