I have intent put extras in my login.java. Those put extras has some datas from my database. It was passed to my intent fragment which is the profile.java. Sirs, is it possible to pass those intents to my other fragments as well as another activity class? If there is another way to do this can someone please tell me what to use?
Asked
Active
Viewed 387 times
-1
-
Possible duplicate of [Send data from activity to fragment in Android](https://stackoverflow.com/questions/12739909/send-data-from-activity-to-fragment-in-android) – Android Jan 30 '19 at 04:42
1 Answers
0
You can use Intent
to achieve what you need. Please do check out this link to understand what it is all about.
First of all, declare and initialize in the first activity a new Intent
object and the string you will pass:
Intent myIntent = new Intent(YourFirstActivity.this, YourSecondActivity.class)
String myString = "string";
i.putExtra("STRING", myString);
Then you will get the extra you have just put in the other activity, declearing a new intent:
Intent mySecondIntent = getIntent();
String stringIWantToGet = mySecondIntent.getStringExtra("STRING")
I hope this short guide to be useful.

Eminent Emperor Penguin
- 835
- 1
- 7
- 21