AlphaOmega
AlphaOmega

Reputation: 45

How can I send data across activities to display a message?

I'm creating something kinda simple I guess and I ran into a few issues.

The app scheme basically goes like that: Main screen display's info/news -> drawer (user selects option) -> -> open's a list -> upon clicking, 2 FAB's appear one for reading comments and one for sending one -> send FAB open's a form.

Now what I'm trying to do is have a "send" button (already done reading the reading of the info entered) and I want it to send it to the "reading" page where it'll stack one on another.

say reading page contains the message: XXX YYY and another user sends ZZZ UUU the reading page will become: ZZZ UUU XXX YYY

I will make the reading page with a send button instead of 2 activities in the near future but it's also for expanding my knowledge.

How can I send the data and have the message displayed on the reading screen?

Also, how can I create a dynamic page for the reading for every section of the list? instead of creating over 100 reading pages?

Thanks :)

Upvotes: 0

Views: 63

Answers (2)

Javier Saurett
Javier Saurett

Reputation: 26

Use putExtra on your intent

    Intent intent = new Intent(getBaseContext(), MyActivity.class);
    intent.putExtra("My_Extra_Param", extra);
    startActivity(intent)

Upvotes: 1

sam nikzad
sam nikzad

Reputation: 1360

For sending data between Activities you must send data with intent to other Activity.

Look at this : How do I pass data between activities on Android

OR

Also you can save your temporary data into Sharedpreferences and retrive into another Activity

see this tutorials : Link1 , link2

Upvotes: 0

Related Questions